You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
box-o-sand/cookbook/015/hodgepodge/app/controllers/application_controller.rb

22 lines
529 B

class ApplicationController < ActionController::Base
before_filter :set_user
protect_from_forgery
protected
def set_user
@user = User.find(session[:id]) if @user.nil? && session[:id]
end
def login_required
return true if @user
access_denied
return false
end
def access_denied
session[:return_to] = request.request_uri
flash[:error] = 'Oops. You need to login before you can view that page.'
redirect_to :controller => 'user', :action => 'login'
end
end