#--- # Excerpted from "Agile Web Development with Rails, 2nd Ed." # We make no guarantees that this code is fit for any purpose. # Visit http://www.pragmaticprogrammer.com/titles/rails2 for more book information. #--- class ApplicationController < ActionController::Base # Pick a unique cookie name to distinguish our session data from others' session :session_key => '_depot_session_id' private def authorize unless User.find_by_id(session[:user_id]) flash[:notice] = "Please log in" redirect_to(:controller => "login", :action => "login") end end end