質問編集履歴
2
バージョン情報追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -78,6 +78,40 @@
|
|
78
78
|
|
79
79
|
|
80
80
|
|
81
|
+
そのまま処理を進めると、やはりDBに格納する直前でバリデーションがかかります。
|
82
|
+
|
83
|
+
```terminal
|
84
|
+
|
85
|
+
Started POST "/admin/project/complete" for ::1 at 2021-01-29 04:52:18 +0900
|
86
|
+
|
87
|
+
Processing by ProjectsController#complete as HTML
|
88
|
+
|
89
|
+
Parameters: {"utf8"=>"✓", "authenticity_token"=>"Bl4b0y0RxyelZ4+fe+rF81IuJxjgB0uw3NROpcyJEnM/kwPFhPTjRjj3YYNQSBYe6q462QQCiibO+GZZkVXbcA==", "project"=>{"page_title"=>"wet", "page_description"=>"wet", "category_id"=>"1", "image"=>"/uploads/tmp/1611863536-108188832449489-0007-9172/4F24F1AA-6D96-4ECA-93B2-517767B400CE.JPG", "contents"=>"<p>qwet</p>"}, "commit"=>"内容を確認する >"}
|
90
|
+
|
91
|
+
(0.1ms) BEGIN
|
92
|
+
|
93
|
+
↳ app/controllers/projects_controller.rb:24
|
94
|
+
|
95
|
+
(0.1ms) ROLLBACK
|
96
|
+
|
97
|
+
↳ app/controllers/projects_controller.rb:24
|
98
|
+
|
99
|
+
Completed 422 Unprocessable Entity in 3ms (ActiveRecord: 0.2ms)
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
ActiveRecord::RecordInvalid (バリデーションに失敗しました: Imageを入力してください):
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
app/controllers/projects_controller.rb:24:in `complete'
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
```
|
112
|
+
|
113
|
+
|
114
|
+
|
81
115
|
### 該当のソースコード
|
82
116
|
|
83
117
|
**view/project/new.html.haml**
|
@@ -192,6 +226,18 @@
|
|
192
226
|
|
193
227
|
mount_uploader :image, ImageUploader
|
194
228
|
|
229
|
+
|
230
|
+
|
231
|
+
validates :page_title, presence: true
|
232
|
+
|
233
|
+
validates :page_description, presence: true
|
234
|
+
|
235
|
+
validates :category_id, presence: true
|
236
|
+
|
237
|
+
validates :image, presence: true
|
238
|
+
|
239
|
+
validates :contents, presence: true
|
240
|
+
|
195
241
|
end
|
196
242
|
|
197
243
|
```
|
1
バージョン情報追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -282,4 +282,6 @@
|
|
282
282
|
|
283
283
|
mysql Ver 14.14 Distrib 5.7.32, for osx10.15 (x86_64) using EditLine wrapper
|
284
284
|
|
285
|
+
carrierwave (2.1.0)
|
286
|
+
|
285
|
-
```
|
287
|
+
```
|