Class: UserSessionsController

Inherits:
ApplicationController show all
Defined in:
lib/app/controllers/user_sessions_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/app/controllers/user_sessions_controller.rb', line 4

def create
  @user_session = UserSession.new params[:user_session]
  
  @user_session.save do |result|
    if result
      flash[:success] = "Welcome back"
      
      redirect_to root_url
    else
      render :action => :new
    end
  end
end

#destroyObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/app/controllers/user_sessions_controller.rb', line 22

def destroy
  if 
    .destroy
    flash[:success] = "You are now logged out."
  else
    flash[:warning] = "You are already logged out."
  end
  
  redirect_to root_url
end

#newObject



18
19
20
# File 'lib/app/controllers/user_sessions_controller.rb', line 18

def new
  @user_session = UserSession.new
end