Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # views/admins/index.html.erb
- <%= link_to 'logout', :controller => 'sessions', :action => 'destroy' %>.
- # controllers/sessions_controller.rb
- class SessionsController < ApplicationController
- layout "sessions"
- def index
- end
- def create
- if params[:password] == 'foobar'
- session[:password] = true
- flash[:notice] = "Successfully logged in"
- redirect_to :controller => 'admins', :action => 'index'
- else
- flash[:notice] = "Invalid user/password combination"
- redirect_to :controller => 'sessions', :action => 'index'
- end
- end
- def destroy
- session[:password] = false
- flash[:notice] = "Successfully logged out"
- redirect_to :controller => 'sessions', :action => 'index'
- end
- end
- # the error when pressing the "logout" button on the index page
- Unknown action
- No action responded to show. Actions: create, destroy, and index
Add Comment
Please, Sign In to add comment