質問編集履歴
3
createメソッドのcreateをnewに変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -162,7 +162,7 @@
|
|
162
162
|
|
163
163
|
def create
|
164
164
|
|
165
|
-
@prototype = Prototype.
|
165
|
+
@prototype = Prototype.*new*(prototype_params)
|
166
166
|
|
167
167
|
if @prototype.save
|
168
168
|
|
2
saveに!をつけたところこのようなエラー文が出ました、
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,41 +20,81 @@
|
|
20
20
|
|
21
21
|
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
```
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
(
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
23
|
+
エラー文です
|
24
|
+
|
25
|
+
```
|
26
|
+
|
27
|
+
ActiveRecord::RecordInvalid in PrototypesController#create
|
28
|
+
|
29
|
+
Validation failed: Image can't be blank
|
30
|
+
|
31
|
+
Extracted source (around line #13):
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
def create
|
36
|
+
|
37
|
+
@prototype = Prototype.create(prototype_params)
|
38
|
+
|
39
|
+
if @prototype.save!
|
40
|
+
|
41
|
+
redirect_to root_path
|
42
|
+
|
43
|
+
else
|
44
|
+
|
45
|
+
render :new
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
Rails.root: /Users/kamiyaryota/Desktop/projects/protospace-31035
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
Application Trace | Framework Trace | Full Trace
|
54
|
+
|
55
|
+
app/controllers/prototypes_controller.rb:13:in `create'
|
56
|
+
|
57
|
+
Request
|
58
|
+
|
59
|
+
Parameters:
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
{"authenticity_token"=>"X/fnWlXUYadtT1MdGuTVyinnpu2B/riCk3iqiFXD3HMV40FTl0eD+nyhOPxtSVP+LSwYDYjHDqkZ3HnYkVkLiQ==",
|
64
|
+
|
65
|
+
"prototype"=>
|
66
|
+
|
67
|
+
{"title"=>"aaa",
|
68
|
+
|
69
|
+
"catct_copy"=>"aaa",
|
70
|
+
|
71
|
+
"concept"=>"aaaa",
|
72
|
+
|
73
|
+
"image"=>
|
74
|
+
|
75
|
+
#<ActionDispatch::Http::UploadedFile:0x00007fe8ead15300
|
76
|
+
|
77
|
+
@content_type="image/png",
|
78
|
+
|
79
|
+
@headers="Content-Disposition: form-data; name=\"prototype[image]\"; filename=\"test_image.png\"\r\n" + "Content-Type: image/png\r\n",
|
80
|
+
|
81
|
+
@original_filename="test_image.png",
|
82
|
+
|
83
|
+
@tempfile=#<File:/var/folders/4y/hbjp90hd2rl1bfd0m4kczr3m0000gn/T/RackMultipart20201023-27843-i4n9cr.png>>},
|
84
|
+
|
85
|
+
"commit"=>"保存する"}
|
86
|
+
|
87
|
+
Toggle session dump
|
88
|
+
|
89
|
+
Toggle env dump
|
90
|
+
|
91
|
+
Response
|
92
|
+
|
93
|
+
Headers:
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
None
|
58
98
|
|
59
99
|
```
|
60
100
|
|
@@ -160,7 +200,9 @@
|
|
160
200
|
|
161
201
|
|
162
202
|
|
163
|
-
model
|
203
|
+
model
|
204
|
+
|
205
|
+
prototype.rbです
|
164
206
|
|
165
207
|
```ryby
|
166
208
|
|
@@ -192,6 +234,44 @@
|
|
192
234
|
|
193
235
|
|
194
236
|
|
237
|
+
model
|
238
|
+
|
239
|
+
user.rbです
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
```ruby
|
244
|
+
|
245
|
+
class User < ApplicationRecord
|
246
|
+
|
247
|
+
# Include default devise modules. Others available are:
|
248
|
+
|
249
|
+
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
|
250
|
+
|
251
|
+
devise :database_authenticatable, :registerable,
|
252
|
+
|
253
|
+
:recoverable, :rememberable, :validatable
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
has_many :prototypes
|
258
|
+
|
259
|
+
has_many :comments
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
validates :name, presence: true
|
264
|
+
|
265
|
+
validates :profile, presence: true
|
266
|
+
|
267
|
+
validates :occupation, presence: true
|
268
|
+
|
269
|
+
validates :position, presence: true
|
270
|
+
|
271
|
+
end
|
272
|
+
|
273
|
+
```
|
274
|
+
|
195
275
|
|
196
276
|
|
197
277
|
*投稿ページです*
|
1
codeの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -54,7 +54,9 @@
|
|
54
54
|
|
55
55
|
[Webpacker] Everything's up-to-date. Nothing to do
|
56
56
|
|
57
|
-
Completed 200 OK in 26ms (Views: 20.3ms | ActiveRecord: 0.7ms | Allocations: 14372)
|
57
|
+
Completed 200 OK in 26ms (Views: 20.3ms | ActiveRecord: 0.7ms | Allocations: 14372)
|
58
|
+
|
59
|
+
```
|
58
60
|
|
59
61
|
|
60
62
|
|