質問編集履歴

9

タイトル

2018/04/08 08:52

投稿

naoya.n
naoya.n

スコア26

test CHANGED
@@ -1 +1 @@
1
- railsでルーティングがうまくいかない
1
+ rake routesのurlはあってるはずなのにルーティングが通らない
test CHANGED
@@ -1,4 +1,6 @@
1
1
  railsのwebアプリでいいね機能を実装したいです。
2
+
3
+
2
4
 
3
5
  ルーティングが間違っているのか、chromeでlocalhostで検証していいねのボタンをクリックしたところ、ビューには何も変化はなく、コンソールでは
4
6
 

8

追加

2018/04/08 08:52

投稿

naoya.n
naoya.n

スコア26

test CHANGED
File without changes
test CHANGED
@@ -34,7 +34,7 @@
34
34
 
35
35
 
36
36
 
37
- コンソールで確認できるurlとrake routesでのurlは一致しているように見えるのですがなぜか通りません。
37
+ ブラウザの検証のコンソールで確認できるurlとrake routesでのurlは一致しているように見えるのですがなぜか通りません。
38
38
 
39
39
 
40
40
 

7

追加

2018/04/08 05:32

投稿

naoya.n
naoya.n

スコア26

test CHANGED
File without changes
test CHANGED
@@ -31,6 +31,10 @@
31
31
 
32
32
 
33
33
  likes controllerのdestroyのはじめにbinding.pryをつけても同じエラーなので、likes#destroy(またはcreate)にパスが通ってないみたいです、、
34
+
35
+
36
+
37
+ コンソールで確認できるurlとrake routesでのurlは一致しているように見えるのですがなぜか通りません。
34
38
 
35
39
 
36
40
 

6

追加

2018/04/08 03:38

投稿

naoya.n
naoya.n

スコア26

test CHANGED
File without changes
test CHANGED
@@ -4,7 +4,13 @@
4
4
 
5
5
 
6
6
 
7
+ 色付きのハートクリック時(destroy)
8
+
7
9
  POST http://localhost:3000/translations/103/likes/2 404 (Not Found)
10
+
11
+ 色なしのハートクリック時(create)
12
+
13
+ POST http://localhost:3000/translations/104/likes 404 (Not Found)
8
14
 
9
15
 
10
16
 

5

順番替え

2018/04/08 03:36

投稿

naoya.n
naoya.n

スコア26

test CHANGED
File without changes
test CHANGED
@@ -11,6 +11,16 @@
11
11
  となっており、ルーティングがうまく行ってないみたいなのですが、どこが悪いのかよく分かりません。
12
12
 
13
13
  どなたか教えていただけませんか!!
14
+
15
+
16
+
17
+ コンソールでrake routesすると、
18
+
19
+ translation_likes POST /translations/:translation_id/likes(.:format) likes#create
20
+
21
+ translation_like DELETE /translations/:translation_id/likes/:id(.:format) likes#destroy
22
+
23
+ となってます。
14
24
 
15
25
 
16
26
 
@@ -85,19 +95,3 @@
85
95
  $("#like-buttons").html("<%= j(render partial: 'like', locals: { translations: @translation, likes: @likes, like: @like}) %>")
86
96
 
87
97
  ```
88
-
89
-
90
-
91
-
92
-
93
- コンソールでrake routesすると、
94
-
95
- translation_likes POST /translations/:translation_id/likes(.:format) likes#create
96
-
97
- translation_like DELETE /translations/:translation_id/likes/:id(.:format) likes#destroy
98
-
99
-
100
-
101
-
102
-
103
- となってます。

4

説名追加

2018/04/08 02:23

投稿

naoya.n
naoya.n

スコア26

test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,6 @@
1
1
  railsのwebアプリでいいね機能を実装したいです。
2
2
 
3
- ルーティングが間違っているのか、chromeでlocalhostで検証したところ、コンソールで
3
+ ルーティングが間違っているのか、chromeでlocalhostで検証していいねのボタンをクリックしたところ、ビューには何も変化はなく、コンソールで
4
4
 
5
5
 
6
6
 

3

説名追加

2018/04/07 08:57

投稿

naoya.n
naoya.n

スコア26

test CHANGED
File without changes
test CHANGED
@@ -11,6 +11,10 @@
11
11
  となっており、ルーティングがうまく行ってないみたいなのですが、どこが悪いのかよく分かりません。
12
12
 
13
13
  どなたか教えていただけませんか!!
14
+
15
+
16
+
17
+ likes controllerのdestroyのはじめにbinding.pryをつけても同じエラーなので、likes#destroy(またはcreate)にパスが通ってないみたいです、、
14
18
 
15
19
 
16
20
 

2

タグ

2018/04/07 08:56

投稿

naoya.n
naoya.n

スコア26

test CHANGED
File without changes
test CHANGED
File without changes

1

追加

2018/04/07 08:45

投稿

naoya.n
naoya.n

スコア26

test CHANGED
File without changes
test CHANGED
@@ -58,6 +58,12 @@
58
58
 
59
59
 
60
60
 
61
+ <%= button_to translation_likes_path(translation_id: translation.id), id: "like-button", class: "btn-like", remote: true do %>
62
+
63
+ <%= image_tag('/icons/like.png') %>
64
+
65
+ <% end %>
66
+
61
67
  ```
62
68
 
63
69
  likes/destroy.js.erb
@@ -68,12 +74,26 @@
68
74
 
69
75
  ```
70
76
 
77
+ likes/create.js.erb
78
+
79
+ ```js
80
+
81
+ $("#like-buttons").html("<%= j(render partial: 'like', locals: { translations: @translation, likes: @likes, like: @like}) %>")
82
+
83
+ ```
84
+
85
+
86
+
71
87
 
72
88
 
73
89
  コンソールでrake routesすると、
90
+
91
+ translation_likes POST /translations/:translation_id/likes(.:format) likes#create
74
92
 
75
93
  translation_like DELETE /translations/:translation_id/likes/:id(.:format) likes#destroy
76
94
 
77
95
 
78
96
 
97
+
98
+
79
99
  となってます。