質問編集履歴

3

修正

2017/05/30 03:10

投稿

innjera
innjera

スコア132

test CHANGED
File without changes
test CHANGED
@@ -256,32 +256,84 @@
256
256
 
257
257
 
258
258
 
259
- UserController
259
+ `User Model`の`CRUD`には`accounts_controller`を使用していま
260
+
261
+
260
262
 
261
263
  ```ruby
262
264
 
263
- class User::UsersController < User::Base
265
+ class User::AccountsController < User::Base
266
+
264
-
267
+ #before_action :signin_required
268
+
265
- # before_action :check_account
269
+ #before_action :check_account
266
-
267
-
268
-
270
+
269
- def index
271
+ before_action :authenticate_user!
270
-
272
+
271
- @users = User.all
273
+ before_action :search_preparation
272
-
273
- end
274
274
 
275
275
 
276
276
 
277
277
  def show
278
278
 
279
- @user = User.find(params[:id])
279
+ @user = current_user
280
-
281
- @lessons = @user.adviser.lessons
280
+
282
-
283
- end
281
+ end
282
+
283
+
284
+
284
-
285
+ def edit
286
+
287
+ @user = current_user
288
+
285
- end
289
+ end
290
+
291
+
292
+
293
+ def update
294
+
295
+ @user = current_user
296
+
297
+ @user.assign_attributes(user_params)
298
+
299
+ if @user.save
300
+
301
+ redirect_to :user_account, notice: "更新しました。"
302
+
303
+ else
304
+
305
+ render "edit"
306
+
307
+ end
308
+
309
+ end
310
+
311
+
312
+
313
+ def icon_edit
314
+
315
+ @user = current_user
316
+
317
+ end
318
+
319
+
320
+
321
+ private def user_params
322
+
323
+ attrs = [
324
+
325
+ :email, :family_name, :given_name, :family_name_kana, :given_name_kana,
326
+
327
+ :user_name, :address, :user_icon, :remove_user_icon
328
+
329
+ ]
330
+
331
+ params.require(:user).permit(attrs)
332
+
333
+ end
334
+
335
+ end
336
+
337
+
286
338
 
287
339
  ```

2

UserController追記

2017/05/30 03:10

投稿

innjera
innjera

スコア132

test CHANGED
File without changes
test CHANGED
@@ -253,3 +253,35 @@
253
253
  updated_at :datetime not null
254
254
 
255
255
  ```
256
+
257
+
258
+
259
+ UserControllerです
260
+
261
+ ```ruby
262
+
263
+ class User::UsersController < User::Base
264
+
265
+ # before_action :check_account
266
+
267
+
268
+
269
+ def index
270
+
271
+ @users = User.all
272
+
273
+ end
274
+
275
+
276
+
277
+ def show
278
+
279
+ @user = User.find(params[:id])
280
+
281
+ @lessons = @user.adviser.lessons
282
+
283
+ end
284
+
285
+ end
286
+
287
+ ```

1

messageのtable追記

2017/05/30 02:23

投稿

innjera
innjera

スコア132

test CHANGED
File without changes
test CHANGED
@@ -217,3 +217,39 @@
217
217
  end
218
218
 
219
219
  ```
220
+
221
+ ```ruby
222
+
223
+ message, applicant message, adviser messageのテーブル
224
+
225
+ applicant messageとadviser messageはmessageを継承しているのみです
226
+
227
+
228
+
229
+ id :integer not null, primary key
230
+
231
+ user_id :integer not null
232
+
233
+ lesson_id :integer
234
+
235
+ adviser_id :integer
236
+
237
+ applicant_id :integer
238
+
239
+ root_id :integer
240
+
241
+ parent_id :integer
242
+
243
+ type :string not null
244
+
245
+ status :string default("new"), not null
246
+
247
+ body :text
248
+
249
+ last_reply_date :datetime
250
+
251
+ created_at :datetime not null
252
+
253
+ updated_at :datetime not null
254
+
255
+ ```