User Controller Flashcards
1
Q
(USER) def new
A
def new
@user = User.new
render :new
end
2
Q
(USER) def index
A
@users = User.all
render :index
end
3
Q
(USER) def create
A
@user = User.create(user_params)
if @user.save log_in!(user) redirect_to users_url else flash[:errors] = @user.errors.full_messages render :new end
4
Q
(USER) def show
A
@user = User.find(params[:id])
render :show
end
5
Q
(USER) def user_params
A
params.require(:user).permit(:username, :password)
6
Q
def edit
A
@user= User.find(params[:id])
render :edit
end
7
Q
def update
A
@user= User.find(params[:id]) if @user.update_attributes(user_params) redirect_to cat_url(@user) else flash.now[:errors] = @user.errors.full_messages render :edit end end