Skip to content

Instantly share code, notes, and snippets.

@mthomas
Created December 20, 2010 00:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mthomas/747882 to your computer and use it in GitHub Desktop.
Save mthomas/747882 to your computer and use it in GitHub Desktop.
application_controller.rb
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
protect_from_forgery # See ActionController::RequestForgeryProtection for details
private
def require_user
unless current_user
flash[:notice] = "You must be logged in to access that page"
redirect_to new_session_url
return false
end
end
def require_no_user
if current_user
flash[:notice] = "You must be logged out to access that page"
redirect_to current_user
return false
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment