You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
892 B
45 lines
892 B
class UsersController < ApplicationController
|
|
def index
|
|
@users = User.all
|
|
end
|
|
def new
|
|
@user = User.new
|
|
end
|
|
def show
|
|
set_user
|
|
end
|
|
def create
|
|
@user = User.new(user_params)
|
|
if @user.save
|
|
redirect_to @user, notice: "Thanks for signing up!"
|
|
else
|
|
render :new, status: :unprocessable_entity
|
|
end
|
|
end
|
|
def edit
|
|
set_user
|
|
end
|
|
def update
|
|
set_user
|
|
if @user.update(user_params)
|
|
redirect_to @user, notice: "Account successfully updated!"
|
|
else
|
|
render :new, status: :unprocessable_entity
|
|
end
|
|
end
|
|
def destroy
|
|
set_user
|
|
@user.destroy
|
|
redirect_to movies_url, status: :see_other, alert: "Account successfully deleted!"
|
|
end
|
|
|
|
private
|
|
def set_user
|
|
@user = User.find(params[:id])
|
|
end
|
|
|
|
def user_params
|
|
params.require(:user).permit(:name, :email, :password, :password_confirmation)
|
|
end
|
|
end
|