Class: SessionsController
- Inherits:
-
ApplicationController
- Object
- ControllerBase
- ApplicationController
- SessionsController
- Defined in:
- lib/scaffold/app/controllers/sessions_controller.rb
Constant Summary
Constants included from ControllerCallbacks
Instance Attribute Summary
Attributes inherited from ControllerBase
Instance Method Summary collapse
Methods inherited from ApplicationController
#current_user, #ensure_login, #ensure_logout, #logged_in?, #login, #logout
Methods inherited from ControllerBase
#form_authenticity_token, #initialize, #invoke_action, #link_to, protect_from_forgery, #root_url
Methods included from ControllerCallbacks
Constructor Details
This class inherits a constructor from ControllerBase
Instance Method Details
#create ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/scaffold/app/controllers/sessions_controller.rb', line 8 def create username = session_params[:username] password = session_params[:password] @user = User.find_by_credentials(username, password) if @user login(@user) redirect_to root_url else flash.now[:errors] = ['invalid username/password'] render :new end end |
#destroy ⇒ Object
22 23 24 25 |
# File 'lib/scaffold/app/controllers/sessions_controller.rb', line 22 def destroy logout redirect_to new_sessions_url end |