Class: UsersController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/users_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/users_controller.rb', line 7

def create
  if params[:commit] === 'Sign up'
    $user = User.create(user_params)
    if $user.save
      session[:user_id] = $user.id
      redirect_to root_path,
        notice: 'Sign in successfull'
    else
      redirect_to :back,
        notice: 'Problems creeting a user'
    end
  else
    redirect_to :back
  end
end

#indexObject



3
4
5
# File 'app/controllers/users_controller.rb', line 3

def index

end

#user_paramsObject



23
24
25
# File 'app/controllers/users_controller.rb', line 23

def user_params
  params.permit(:name, :email, :password, :password_confirmation)
end