質問編集履歴

5

インデントを揃えました。

2020/08/21 03:13

投稿

latte217
latte217

スコア19

test CHANGED
File without changes
test CHANGED
@@ -327,3 +327,65 @@
327
327
  </div>
328
328
 
329
329
  ```
330
+
331
+
332
+
333
+ #改めてインデント揃えました。
334
+
335
+ ```ja:
336
+
337
+ activerecord:
338
+
339
+ errors:
340
+
341
+ models:
342
+
343
+ user:
344
+
345
+ attributes:
346
+
347
+ name:
348
+
349
+ blank: :空白になっています。
350
+
351
+ email:
352
+
353
+ blank: :空白になっています。
354
+
355
+ invalid: :正しいメールアドレスを登録ください。
356
+
357
+ password:
358
+
359
+ blank: :空白になっています。
360
+
361
+ too_short: :6文字以上で入力してください。
362
+
363
+ password_confirmation:
364
+
365
+ confirmation: :パスワードが一致しません。
366
+
367
+ staffmember:
368
+
369
+ attributes:
370
+
371
+ code:
372
+
373
+ blank: : 空白登録できません。
374
+
375
+
376
+
377
+ attributes:
378
+
379
+ user:
380
+
381
+ name: 名前
382
+
383
+ email: メールアドレス
384
+
385
+ password_confirmation: Password 再入力
386
+
387
+
388
+
389
+ コード
390
+
391
+ ```

4

改行が間違っていたので、更新しました(モデル)

2020/08/21 03:13

投稿

latte217
latte217

スコア19

test CHANGED
File without changes
test CHANGED
@@ -118,7 +118,9 @@
118
118
 
119
119
 
120
120
 
121
+ ```
122
+
121
- ```class Staffmember < ApplicationRecord
123
+ class Staffmember < ApplicationRecord
122
124
 
123
125
  before_save{ self.code = code.downcase}
124
126
 

3

ビューを追加掲載しました。

2020/08/20 05:18

投稿

latte217
latte217

スコア19

test CHANGED
File without changes
test CHANGED
@@ -207,3 +207,121 @@
207
207
 
208
208
 
209
209
  ```
210
+
211
+
212
+
213
+ ビュー
214
+
215
+ ```<h1>スタッフ登録</h1>
216
+
217
+
218
+
219
+ <div class="row">
220
+
221
+
222
+
223
+ <%= form_with(model: @staff, local: true) do |f| %>
224
+
225
+ <%= render "shared/error_messages", object: f.object %>
226
+
227
+ <section>
228
+
229
+ <h2>基本情報</h2>
230
+
231
+ <div class="form-group col-md-2">
232
+
233
+ <%= f.label :code, "職員番号" %>
234
+
235
+ <%= f.number_field :code %>
236
+
237
+ </div>
238
+
239
+
240
+
241
+ <div class="form-group col-md-2">
242
+
243
+ <%= f.label :password %>
244
+
245
+ <%= f.password_field :password %>
246
+
247
+ </div>
248
+
249
+
250
+
251
+ <div class="form-group col-md-2">
252
+
253
+ <%= f.label :password_confirmation, "Password再入力" %>
254
+
255
+ <%= f.password_field :password_confirmation %>
256
+
257
+ </div>
258
+
259
+
260
+
261
+ <div class="form-group col-md-3">
262
+
263
+ <%= f.label :jpn_name, "氏  名" %>
264
+
265
+ <%= f.text_field :jpn_name %>
266
+
267
+ </div>
268
+
269
+
270
+
271
+ <div class="form-group col-md-3">
272
+
273
+ <%= f.label :kana_name, "カナ氏名" %>
274
+
275
+ <%= f.text_field :kana_name %>
276
+
277
+ </div>
278
+
279
+
280
+
281
+ <div class="form-group col-md-3">
282
+
283
+ <%= f.label :eng_name, "英字氏名" %>
284
+
285
+ <%= f.text_field :eng_name %>
286
+
287
+ </div>
288
+
289
+
290
+
291
+ <div class="form-group col-md-2">
292
+
293
+ <%= f.label :birthday, "生年月日" %>
294
+
295
+ <%= f.date_field :birthday %>
296
+
297
+ </div>
298
+
299
+
300
+
301
+ <div class="form-group col-md-2">
302
+
303
+ <%= f.label :sex, "性別" %>
304
+
305
+ <%= f.select :sex, [['男性', 1], ['女性', 2]],{ selected: 2} %>
306
+
307
+ </div>
308
+
309
+
310
+
311
+ </section>
312
+
313
+
314
+
315
+ <section>
316
+
317
+ <h2>部署情報</h2>
318
+
319
+ </section>
320
+
321
+ <%= f.submit "登 録", class: "btn btn-primary" %>
322
+
323
+ <% end %>
324
+
325
+ </div>
326
+
327
+ ```

2

コントローラーを追加掲載しました

2020/08/20 05:15

投稿

latte217
latte217

スコア19

test CHANGED
File without changes
test CHANGED
@@ -141,3 +141,69 @@
141
141
 
142
142
 
143
143
  ```
144
+
145
+
146
+
147
+ コントローラー
148
+
149
+ ```class StaffmembersController < ApplicationController
150
+
151
+ def index
152
+
153
+ end
154
+
155
+
156
+
157
+ def new
158
+
159
+ @staff = Staffmember.new
160
+
161
+ end
162
+
163
+
164
+
165
+ def create
166
+
167
+ @staff = Staffmember.new(staffmember_params)
168
+
169
+ if @staff.save
170
+
171
+ flash[:success] = "登録されました。"
172
+
173
+ redirect_to @staff
174
+
175
+ else
176
+
177
+ render 'new'
178
+
179
+ end
180
+
181
+ end
182
+
183
+
184
+
185
+ def show
186
+
187
+ @staff = Staffmember.find(params[:id])
188
+
189
+ end
190
+
191
+
192
+
193
+ private
194
+
195
+ def staffmember_params
196
+
197
+ params.require(:staffmember).permit(:code, :password, :password_confirmation, :jpn_name, :kana_name, :eng_name,
198
+
199
+ :birthday, :sex )
200
+
201
+ end
202
+
203
+
204
+
205
+ end
206
+
207
+
208
+
209
+ ```

1

追加情報としてモデルのコードを掲載しました。

2020/08/20 05:13

投稿

latte217
latte217

スコア19

test CHANGED
File without changes
test CHANGED
@@ -109,3 +109,35 @@
109
109
 
110
110
 
111
111
  VS-CODEにてローカル環境にて開発中です。
112
+
113
+
114
+
115
+ ### 追加情報
116
+
117
+ モデル
118
+
119
+
120
+
121
+ ```class Staffmember < ApplicationRecord
122
+
123
+ before_save{ self.code = code.downcase}
124
+
125
+ validates :code, presence: true, uniqueness: true
126
+
127
+ validates :jpn_name, presence: true
128
+
129
+ validates :password, presence: true, length: {minimum: 6}
130
+
131
+ validates :kana_name, presence: true
132
+
133
+ validates :birthday, presence: true
134
+
135
+
136
+
137
+ has_secure_password
138
+
139
+ end
140
+
141
+
142
+
143
+ ```