質問編集履歴
3
createメソッドのcreateをnewに変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -80,7 +80,7 @@
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def create
|
83
|
-
@prototype = Prototype.
|
83
|
+
@prototype = Prototype.*new*(prototype_params)
|
84
84
|
if @prototype.save
|
85
85
|
redirect_to root_path
|
86
86
|
else
|
2
saveに!をつけたところこのようなエラー文が出ました、
title
CHANGED
File without changes
|
body
CHANGED
@@ -9,24 +9,44 @@
|
|
9
9
|
エラーメッセージ
|
10
10
|
|
11
11
|
|
12
|
-
|
12
|
+
エラー文です
|
13
13
|
```
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
14
|
+
ActiveRecord::RecordInvalid in PrototypesController#create
|
15
|
+
Validation failed: Image can't be blank
|
16
|
+
Extracted source (around line #13):
|
17
|
+
|
18
|
+
def create
|
19
|
+
@prototype = Prototype.create(prototype_params)
|
20
|
+
if @prototype.save!
|
21
|
+
redirect_to root_path
|
22
|
+
else
|
23
|
+
render :new
|
24
|
+
|
25
|
+
Rails.root: /Users/kamiyaryota/Desktop/projects/protospace-31035
|
26
|
+
|
27
|
+
Application Trace | Framework Trace | Full Trace
|
28
|
+
app/controllers/prototypes_controller.rb:13:in `create'
|
29
|
+
Request
|
30
|
+
Parameters:
|
31
|
+
|
32
|
+
{"authenticity_token"=>"X/fnWlXUYadtT1MdGuTVyinnpu2B/riCk3iqiFXD3HMV40FTl0eD+nyhOPxtSVP+LSwYDYjHDqkZ3HnYkVkLiQ==",
|
33
|
+
"prototype"=>
|
34
|
+
{"title"=>"aaa",
|
35
|
+
"catct_copy"=>"aaa",
|
36
|
+
"concept"=>"aaaa",
|
37
|
+
"image"=>
|
38
|
+
#<ActionDispatch::Http::UploadedFile:0x00007fe8ead15300
|
39
|
+
@content_type="image/png",
|
40
|
+
@headers="Content-Disposition: form-data; name=\"prototype[image]\"; filename=\"test_image.png\"\r\n" + "Content-Type: image/png\r\n",
|
41
|
+
@original_filename="test_image.png",
|
42
|
+
@tempfile=#<File:/var/folders/4y/hbjp90hd2rl1bfd0m4kczr3m0000gn/T/RackMultipart20201023-27843-i4n9cr.png>>},
|
43
|
+
"commit"=>"保存する"}
|
44
|
+
Toggle session dump
|
45
|
+
Toggle env dump
|
46
|
+
Response
|
47
|
+
Headers:
|
48
|
+
|
49
|
+
None
|
30
50
|
```
|
31
51
|
|
32
52
|
|
@@ -79,7 +99,8 @@
|
|
79
99
|
end
|
80
100
|
```
|
81
101
|
|
82
|
-
model
|
102
|
+
model
|
103
|
+
prototype.rbです
|
83
104
|
```ryby
|
84
105
|
class Prototype < ApplicationRecord
|
85
106
|
has_many :comments
|
@@ -95,7 +116,26 @@
|
|
95
116
|
end
|
96
117
|
```
|
97
118
|
|
119
|
+
model
|
120
|
+
user.rbです
|
98
121
|
|
122
|
+
```ruby
|
123
|
+
class User < ApplicationRecord
|
124
|
+
# Include default devise modules. Others available are:
|
125
|
+
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
|
126
|
+
devise :database_authenticatable, :registerable,
|
127
|
+
:recoverable, :rememberable, :validatable
|
128
|
+
|
129
|
+
has_many :prototypes
|
130
|
+
has_many :comments
|
131
|
+
|
132
|
+
validates :name, presence: true
|
133
|
+
validates :profile, presence: true
|
134
|
+
validates :occupation, presence: true
|
135
|
+
validates :position, presence: true
|
136
|
+
end
|
137
|
+
```
|
138
|
+
|
99
139
|
*投稿ページです*
|
100
140
|
```html
|
101
141
|
<div class="main">
|
1
codeの修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -26,7 +26,8 @@
|
|
26
26
|
Rendered prototypes/_form.html.erb (Duration: 0.7ms | Allocations: 546)
|
27
27
|
Rendered prototypes/new.html.erb within layouts/application (Duration: 0.8ms | Allocations: 617)
|
28
28
|
[Webpacker] Everything's up-to-date. Nothing to do
|
29
|
-
Completed 200 OK in 26ms (Views: 20.3ms | ActiveRecord: 0.7ms | Allocations: 14372)
|
29
|
+
Completed 200 OK in 26ms (Views: 20.3ms | ActiveRecord: 0.7ms | Allocations: 14372)
|
30
|
+
```
|
30
31
|
|
31
32
|
|
32
33
|
該当コード
|