質問編集履歴
5
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,6 +12,12 @@
|
|
12
12
|
|
13
13
|
```
|
14
14
|
|
15
|
+
Showing /Users/nawaryoga/filma/app/views/posts/new.html.erb where line #5 raised:
|
16
|
+
|
17
|
+
undefined method `errors' for nil:NilClass
|
18
|
+
|
19
|
+
|
20
|
+
|
15
21
|
Extracted source (around line #5):
|
16
22
|
|
17
23
|
3 <div class="posts-form-body">
|
4
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -168,6 +168,62 @@
|
|
168
168
|
|
169
169
|
|
170
170
|
|
171
|
+
コントローラ▼
|
172
|
+
|
173
|
+
```
|
174
|
+
|
175
|
+
class PostsController < ApplicationController
|
176
|
+
|
177
|
+
def new
|
178
|
+
|
179
|
+
end
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
def index
|
184
|
+
|
185
|
+
@posts = Post.all.order(created_at: :desc)
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
def create
|
192
|
+
|
193
|
+
@post = Post.new(
|
194
|
+
|
195
|
+
title: params[:title],
|
196
|
+
|
197
|
+
content: params[:content]
|
198
|
+
|
199
|
+
)
|
200
|
+
|
201
|
+
if @post.save
|
202
|
+
|
203
|
+
redirect_to("/posts/index")
|
204
|
+
|
205
|
+
else
|
206
|
+
|
207
|
+
render("/posts/new")
|
208
|
+
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
def show
|
216
|
+
|
217
|
+
@post = Post.find_by(id: params[:id])
|
218
|
+
|
219
|
+
end
|
220
|
+
|
221
|
+
end
|
222
|
+
|
223
|
+
```
|
224
|
+
|
225
|
+
|
226
|
+
|
171
227
|
---
|
172
228
|
|
173
229
|
|
3
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -201,3 +201,9 @@
|
|
201
201
|
- puma
|
202
202
|
|
203
203
|
- MySQL
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
MySQLの`posts`テーブルで記事を管理するようにしていますが、現在どちらにもデータは入っていません。
|
208
|
+
|
209
|
+
カラムは`id` `title` `content` `created_at` `updated_at`で共通しています。
|
2
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -186,6 +186,10 @@
|
|
186
186
|
|
187
187
|
|
188
188
|
|
189
|
+
他にすでに動いている本番環境がありますが、このエラーは出ていません。
|
190
|
+
|
191
|
+
|
192
|
+
|
189
193
|
**本番環境**
|
190
194
|
|
191
195
|
|
1
環境追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -180,4 +180,20 @@
|
|
180
180
|
|
181
181
|
- Ruby2.6.6
|
182
182
|
|
183
|
+
- puma
|
184
|
+
|
185
|
+
- MySQL
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
**本番環境**
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
- EC2
|
194
|
+
|
183
|
-
-
|
195
|
+
- Nginx
|
196
|
+
|
197
|
+
- puma
|
198
|
+
|
199
|
+
- MySQL
|