40 lines
623 B
Ruby
40 lines
623 B
Ruby
class UsersController < ApplicationController
|
|
def new
|
|
@user = User.new
|
|
end
|
|
|
|
def create
|
|
@user = User.new(user_params)
|
|
if @user.save
|
|
log_in @user
|
|
redirect_to main_path
|
|
else
|
|
render 'new'
|
|
end
|
|
end
|
|
|
|
def edit
|
|
@user = current_user
|
|
render 'edit'
|
|
end
|
|
|
|
|
|
def update
|
|
if @user.update_attributes(user_params)
|
|
flash[:success]="profile updated"
|
|
redirect_to @user
|
|
else
|
|
render 'edit'
|
|
end
|
|
end
|
|
|
|
|
|
private
|
|
|
|
def user_params
|
|
params.require(:user).permit(:name, :email, :password,
|
|
:password_confirmation)
|
|
end
|
|
|
|
end
|