teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

users_controller.rbを追加しました

2019/11/18 14:04

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -116,6 +116,32 @@
116
116
  end
117
117
  ```
118
118
 
119
+ users_controller.rb
120
+ ```
121
+ class UsersController < ApplicationController
122
+ def index
123
+ @user = current_user
124
+ @users = User.all
125
+ end
126
+
127
+ def show
128
+ @user = User.find(params[:id])
129
+ @book = Book.new
130
+ @books = @user.books
131
+ end
132
+
133
+ def edit
134
+ @user = User.find(params[:id])
135
+ end
136
+
137
+ private
138
+
139
+ def user_params
140
+ params.require(:user).permit(:name, :introduction, :profile_image_id)
141
+ end
142
+ end
143
+ ```
144
+
119
145
  20191003161330_create_books.rb
120
146
  ```
121
147
  class CreateBooks < ActiveRecord::Migration[5.0]