Guest User

Untitled

a guest
Jun 19th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. # views/admins/index.html.erb
  2. <%= link_to 'logout', :controller => 'sessions', :action => 'destroy' %>.
  3.  
  4. # controllers/sessions_controller.rb
  5. class SessionsController < ApplicationController
  6. layout "sessions"
  7.  
  8. def index
  9. end
  10.  
  11. def create
  12. if params[:password] == 'foobar'
  13. session[:password] = true
  14. flash[:notice] = "Successfully logged in"
  15. redirect_to :controller => 'admins', :action => 'index'
  16. else
  17. flash[:notice] = "Invalid user/password combination"
  18. redirect_to :controller => 'sessions', :action => 'index'
  19. end
  20. end
  21.  
  22. def destroy
  23. session[:password] = false
  24. flash[:notice] = "Successfully logged out"
  25. redirect_to :controller => 'sessions', :action => 'index'
  26. end
  27. end
  28.  
  29. # the error when pressing the "logout" button on the index page
  30. Unknown action
  31.  
  32. No action responded to show. Actions: create, destroy, and index
Add Comment
Please, Sign In to add comment