質問編集履歴
2
変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,12 +1,16 @@
|
|
1
|
+
投稿フォーム送信後に投稿したタイトルと本文の詳細ページに行きたいのですが以下のようなエラーが出ます。
|
2
|
+
|
3
|
+
|
4
|
+
|
1
5
|
Couldn't find Post with 'id'=id
|
2
6
|
|
3
|
-
def show
|
7
|
+
def show
|
4
8
|
|
5
|
-
|
9
|
+
@post=Post.find(params[:id])
|
6
10
|
|
7
|
-
end
|
11
|
+
end
|
8
12
|
|
9
|
-
|
13
|
+
|
10
14
|
|
11
15
|
初心者で申し訳ありませんが教えてくださる方よろしくお願いします。
|
12
16
|
|
@@ -80,7 +84,7 @@
|
|
80
84
|
|
81
85
|
@post.save
|
82
86
|
|
83
|
-
redirect_to post
|
87
|
+
redirect_to post_path(:id)
|
84
88
|
|
85
89
|
end
|
86
90
|
|
1
変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
redirect_toでのエラー
|
1
|
+
至急困っています。redirect_toでのエラー Couldn't find Post with 'id'=id
|
test
CHANGED
@@ -1,8 +1,24 @@
|
|
1
|
+
Couldn't find Post with 'id'=id
|
2
|
+
|
3
|
+
def show
|
4
|
+
|
5
|
+
@post=Post.find(params[:id])
|
6
|
+
|
7
|
+
end
|
8
|
+
|
9
|
+
上記のようなエラーが出てきてしまいます。
|
10
|
+
|
11
|
+
初心者で申し訳ありませんが教えてくださる方よろしくお願いします。
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
1
17
|
index.html.erb
|
2
18
|
|
3
19
|
|
4
20
|
|
5
|
-
<%
|
21
|
+
<% @posts.each do |post| %>
|
6
22
|
|
7
23
|
<%=post.title %>
|
8
24
|
|
@@ -38,7 +54,7 @@
|
|
38
54
|
|
39
55
|
def index
|
40
56
|
|
41
|
-
@posts=Post.all.order(created_at: 'asc')
|
57
|
+
@posts=Post.all.order(created_at: 'asc')
|
42
58
|
|
43
59
|
end
|
44
60
|
|
@@ -46,7 +62,7 @@
|
|
46
62
|
|
47
63
|
def show
|
48
64
|
|
49
|
-
@post=Post.find(params[:id])
|
65
|
+
@post=Post.find(params[:id])
|
50
66
|
|
51
67
|
end
|
52
68
|
|
@@ -60,13 +76,11 @@
|
|
60
76
|
|
61
77
|
def create
|
62
78
|
|
63
|
-
|
79
|
+
@post = Post.new(post_params)
|
64
80
|
|
65
|
-
@post
|
81
|
+
@post.save
|
66
82
|
|
67
|
-
@post.save
|
68
|
-
|
69
|
-
redirect_to posts_path
|
83
|
+
redirect_to posts_path
|
70
84
|
|
71
85
|
end
|
72
86
|
|
@@ -74,13 +88,13 @@
|
|
74
88
|
|
75
89
|
def edit
|
76
90
|
|
77
|
-
post=Post.find(params[:id])
|
91
|
+
post=Post.find(params[:id])
|
78
92
|
|
79
|
-
|
93
|
+
end
|
80
94
|
|
81
95
|
|
82
96
|
|
83
|
-
|
97
|
+
def update
|
84
98
|
|
85
99
|
@post=Post.find(params[:id])
|
86
100
|
|
@@ -88,28 +102,28 @@
|
|
88
102
|
|
89
103
|
redirect_to post_path(:id)
|
90
104
|
|
91
|
-
|
105
|
+
end
|
92
106
|
|
93
107
|
|
94
108
|
|
95
|
-
|
109
|
+
def destroy
|
96
110
|
|
97
|
-
|
111
|
+
@post=Post.find(params[:id])
|
98
112
|
|
99
|
-
|
113
|
+
@post.destroy
|
100
114
|
|
101
|
-
|
115
|
+
redirect_to posts_path
|
102
116
|
|
103
|
-
|
117
|
+
end
|
104
118
|
|
105
119
|
|
106
120
|
|
107
|
-
|
121
|
+
private
|
108
122
|
|
109
|
-
|
123
|
+
def post_params
|
110
124
|
|
111
|
-
|
125
|
+
params.require(:post).permit(:title, :body)
|
112
|
-
|
113
|
-
end
|
114
126
|
|
115
127
|
end
|
128
|
+
|
129
|
+
end
|