Class: UserSessionsController

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

Instance Attribute Summary

Attributes inherited from ActionController::Base

#formats

Instance Method Summary collapse

Methods included from InheritedResources::DSL

included

Methods inherited from ActionController::Base

clear_respond_to, inherit_resources, respond_to, #respond_to, #respond_with, #responder

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/app/controllers/user_sessions_controller.rb', line 9

def create
  @user_session = UserSession.new(params[:user_session])
  if @user_session.save
    flash[:notice] = "Login successful!"
    redirect_back_or_default 
  else
    flash[:notice] = "Invalid login/password."
    render :action => :new
  end
end

#destroyObject



20
21
22
23
24
# File 'lib/app/controllers/user_sessions_controller.rb', line 20

def destroy
  current_user_session.destroy
  flash[:notice] = "Logout successful!"
  redirect_back_or_default 
end

#newObject



5
6
7
# File 'lib/app/controllers/user_sessions_controller.rb', line 5

def new
  @user_session = UserSession.new
end