質問編集履歴
5
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,27 +20,15 @@
|
|
20
20
|
|
21
21
|
```
|
22
22
|
|
23
|
-
.category-btn
|
23
|
+
.category-btn
|
24
24
|
|
25
|
-
= link_to
|
25
|
+
= link_to categories_path(category.id), class: "btn" do
|
26
26
|
|
27
|
-
%p.four-text 少年漫画
|
27
|
+
%p.four-text 少年漫画
|
28
28
|
|
29
29
|
```
|
30
30
|
|
31
31
|
現在こういう感じにpathの指定をしています。
|
32
|
-
|
33
|
-
showアクションなのかindexアクションでいいのかわからずですが今はshowアクションに下記のような記述をしています。
|
34
|
-
|
35
|
-
```CategoriesControlle
|
36
|
-
|
37
|
-
def show
|
38
|
-
|
39
|
-
@category = Category.find(params[:id])
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
```
|
44
32
|
|
45
33
|
|
46
34
|
|
@@ -50,21 +38,31 @@
|
|
50
38
|
|
51
39
|
```
|
52
40
|
|
53
|
-
|
41
|
+
NameError in Books#index
|
54
42
|
|
55
|
-
No route matches [GET] "/category_path(category_id:%201)"
|
56
|
-
|
57
|
-
|
43
|
+
Showing /Users/〇〇/projects/mybook/app/views/books/index.html.haml where line #14 raised:
|
58
44
|
|
59
45
|
|
60
46
|
|
61
|
-
|
47
|
+
undefined local variable or method `category' for #<#<Class:0x00007fbd47d5b9f0>:0x00007fbd47d59718>
|
62
48
|
|
63
|
-
|
49
|
+
Did you mean? category_url
|
64
50
|
|
65
|
-
|
51
|
+
Extracted source (around line #14):
|
66
52
|
|
67
53
|
|
54
|
+
|
55
|
+
.category
|
56
|
+
|
57
|
+
.category-btn
|
58
|
+
|
59
|
+
= link_to categories_path(category.id), class: "btn" do
|
60
|
+
|
61
|
+
%p.four-text 少年漫画
|
62
|
+
|
63
|
+
= link_to "#", class: "btn" do
|
64
|
+
|
65
|
+
%p.four-text 少女漫画
|
68
66
|
|
69
67
|
|
70
68
|
|
4
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
.category-btn
|
24
24
|
|
25
|
-
= link_to category_path(category_id: 1), class: "btn" do
|
25
|
+
= link_to "category_path(category_id: 1)", class: "btn" do
|
26
26
|
|
27
27
|
%p.four-text 少年漫画
|
28
28
|
|
@@ -42,40 +42,34 @@
|
|
42
42
|
|
43
43
|
```
|
44
44
|
|
45
|
+
|
46
|
+
|
45
|
-
|
47
|
+
ボタンを押すと下記のようなRouting Errorが出てしまいます。
|
46
48
|
|
47
49
|
#エラーメッセージ
|
50
|
+
|
51
|
+
```
|
52
|
+
|
53
|
+
Routing Error
|
54
|
+
|
55
|
+
No route matches [GET] "/category_path(category_id:%201)"
|
56
|
+
|
57
|
+
Rails.root: /Users/〇〇/projects/mybook
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
Application Trace | Framework Trace | Full Trace
|
62
|
+
|
63
|
+
Routes
|
64
|
+
|
65
|
+
Routes match in priority from top to bottom
|
66
|
+
|
67
|
+
|
48
68
|
|
49
69
|
|
50
70
|
|
51
71
|
```
|
52
72
|
|
53
|
-
ActionController::UrlGenerationError in Books#index
|
54
|
-
|
55
|
-
Showing /Users/〇〇/projects/mybook/app/views/books/index.html.haml where line #14 raised:
|
56
73
|
|
57
74
|
|
58
|
-
|
59
|
-
No route matches {:action=>"show", :category_id=>1, :controller=>"categories"}, missing required keys: [:id]
|
60
|
-
|
61
|
-
Extracted source (around line #14):
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
.category
|
66
|
-
|
67
|
-
.category-btn
|
68
|
-
|
69
|
-
= link_to category_path(category_id: 1), class: "btn" do
|
70
|
-
|
71
|
-
%p.four-text 少年漫画
|
72
|
-
|
73
|
-
= link_to "#", class: "btn" do
|
74
|
-
|
75
|
-
%p.four-text 少女漫画
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
```
|
80
|
-
|
81
75
|
実装の仕方がわかる方がいらっしゃいましたらご教授をお願い致します。
|
3
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,9 +22,9 @@
|
|
22
22
|
|
23
23
|
.category-btn
|
24
24
|
|
25
|
-
|
25
|
+
= link_to category_path(category_id: 1), class: "btn" do
|
26
26
|
|
27
|
-
|
27
|
+
%p.four-text 少年漫画
|
28
28
|
|
29
29
|
```
|
30
30
|
|
2
修正
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
category_idが同じものだけを表示させる
|
1
|
+
category_idが同じものだけを表示させる実装がしたい
|
test
CHANGED
File without changes
|
1
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,13 +6,13 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
-
|
9
|
+
- booksテーブルには全ての本のデータが入っている(name,price,author,category_id)
|
10
10
|
|
11
|
-
|
11
|
+
- imagesテーブルには本の画像のデータ(image,book_id)
|
12
12
|
|
13
|
-
|
13
|
+
- categoriesテーブルには少年漫画、少女漫画などカテゴリー名のデータが入ってる(name)
|
14
14
|
|
15
|
-
|
15
|
+
- book_categoriesテーブルにはbooksテーブルとcategoriesテーブルのデータがある(book_id,category_id)
|
16
16
|
|
17
17
|
|
18
18
|
|