質問編集履歴
3
別手法の結果を追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
自分の職歴を投稿する機能を作成しています。
|
2
2
|
|
3
3
|
|
4
4
|
|
@@ -48,6 +48,14 @@
|
|
48
48
|
|
49
49
|
```ここに言語を入力
|
50
50
|
|
51
|
+
def new
|
52
|
+
|
53
|
+
@career = Career.new
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
|
51
59
|
def create
|
52
60
|
|
53
61
|
Career.create(
|
@@ -127,3 +135,79 @@
|
|
127
135
|
|
128
136
|
|
129
137
|
という(1i)〜(3i)がうまく情報渡せていないように見えます。
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
---
|
146
|
+
|
147
|
+
追記です。
|
148
|
+
|
149
|
+
controllerのcreateにて career_params を読み込むように変えてみましたが、
|
150
|
+
|
151
|
+
今度は ROLLBACK が起きて全て登録できなくなってしまいました…。
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
controllers/careers_controller.rb
|
156
|
+
|
157
|
+
```ここに言語を入力
|
158
|
+
|
159
|
+
def new
|
160
|
+
|
161
|
+
@career = Career.new
|
162
|
+
|
163
|
+
end
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
def create
|
168
|
+
|
169
|
+
@career = Career.create(career_params)
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
logger.debug @career.errors.inspect
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
```
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
エラー:
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
```ここに言語を入力
|
186
|
+
|
187
|
+
Started POST "/careers" for 127.0.0.1 at 2018-12-09 22:40:58 +0900
|
188
|
+
|
189
|
+
Processing by CareersController#create as HTML
|
190
|
+
|
191
|
+
Parameters: {"utf8"=>"✓", "authenticity_token"=>"Q3E41N8ZMgNky4zx6TH/thUk2rVqQMmJpDprCBhbuUi+AjQINyLj6rz9h1hZxjzejUyrQ4xBtRBYbmOIOqLMkg==", "career"=>{"job_category"=>"111", "annual_salary"=>"2222", "position"=>"3333", "start_date(1i)"=>"1989", "start_date(2i)"=>"1", "start_date(3i)"=>"1", "end_date(1i)"=>"1989", "end_date(2i)"=>"1", "end_date(3i)"=>"1"}, "commit"=>"送信"}
|
192
|
+
|
193
|
+
User Load (1.0ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 9 ORDER BY `users`.`id` ASC LIMIT 1
|
194
|
+
|
195
|
+
↳ app/controllers/careers_controller.rb:86
|
196
|
+
|
197
|
+
(0.3ms) BEGIN
|
198
|
+
|
199
|
+
↳ app/controllers/careers_controller.rb:36
|
200
|
+
|
201
|
+
(2.0ms) ROLLBACK
|
202
|
+
|
203
|
+
↳ app/controllers/careers_controller.rb:36
|
204
|
+
|
205
|
+
#<ActiveModel::Errors:0x00007fd55dc2fc88 @base=#<Career id: nil, job_category: "111", created_at: nil, updated_at: nil, user_id: nil, annual_salary: 2222, position: "3333", start_date: "1989-01-01", end_date: "1989-01-01">, @messages={:user=>["を入力してください"]}, @details={:user=>[{:error=>:blank}]}>
|
206
|
+
|
207
|
+
Rendering careers/create.html.erb within layouts/application
|
208
|
+
|
209
|
+
Rendered careers/create.html.erb within layouts/application (0.5ms)
|
210
|
+
|
211
|
+
Completed 200 OK in 278ms (Views: 225.5ms | ActiveRecord: 3.4ms)
|
212
|
+
|
213
|
+
```
|
2
エラーの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -77,3 +77,53 @@
|
|
77
77
|
end
|
78
78
|
|
79
79
|
```
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
エラー
|
84
|
+
|
85
|
+
```ここに言語を入力
|
86
|
+
|
87
|
+
Started POST "/careers" for 127.0.0.1 at 2018-12-09 14:07:37 +0900
|
88
|
+
|
89
|
+
Processing by CareersController#create as HTML
|
90
|
+
|
91
|
+
Parameters: {"utf8"=>"✓", "authenticity_token"=>"XXXXXXXXXXXXX/X/XXXXXX==", "career"=>{"job_category"=>"100", "annual_salary"=>"200", "position"=>"300", "start_date(1i)"=>"1989", "start_date(2i)"=>"1", "start_date(3i)"=>"4", "end_date(1i)"=>"1990", "end_date(2i)"=>"2", "end_date(3i)"=>"3"}, "commit"=>"送信"}
|
92
|
+
|
93
|
+
User Load (0.8ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 9 ORDER BY `users`.`id` ASC LIMIT 1
|
94
|
+
|
95
|
+
↳ app/controllers/careers_controller.rb:72
|
96
|
+
|
97
|
+
(0.4ms) BEGIN
|
98
|
+
|
99
|
+
↳ app/controllers/careers_controller.rb:17
|
100
|
+
|
101
|
+
User Load (0.7ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 9 LIMIT 1
|
102
|
+
|
103
|
+
↳ app/controllers/careers_controller.rb:17
|
104
|
+
|
105
|
+
Career Create (4.5ms) INSERT INTO `careers` (`job_category`, `created_at`, `updated_at`, `user_id`, `annual_salary`, `position`) VALUES ('100', '2018-12-09 14:07:37', '2018-12-09 14:07:37', 9, 200, '300')
|
106
|
+
|
107
|
+
↳ app/controllers/careers_controller.rb:17
|
108
|
+
|
109
|
+
(81.8ms) COMMIT
|
110
|
+
|
111
|
+
↳ app/controllers/careers_controller.rb:17
|
112
|
+
|
113
|
+
#<ActiveModel::Errors:0x00007f8901294e38 @base=#<Career id: 64, job_category: "100", created_at: "2018-12-09 05:07:37", updated_at: "2018-12-09 05:07:37", user_id: 9, annual_salary: 200, position: "300", start_date: nil, end_date: nil>, @messages={}, @details={}>
|
114
|
+
|
115
|
+
Rendering careers/create.html.erb within layouts/application
|
116
|
+
|
117
|
+
Rendered careers/create.html.erb within layouts/application (0.7ms)
|
118
|
+
|
119
|
+
Completed 200 OK in 722ms (Views: 613.2ms | ActiveRecord: 88.1ms)
|
120
|
+
|
121
|
+
```
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
"start_date(1i)"=>"1989", "start_date(2i)"=>"1", "start_date(3i)"=>"4", "end_date(1i)"=>"1990", "end_date(2i)"=>"2", "end_date(3i)"=>"3"
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
という(1i)〜(3i)がうまく情報渡せていないように見えます。
|
1
タグの追加
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|