Created
February 19, 2009 00:25
-
-
Save tinogomes/66633 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
helper :all # include all helpers, all the time | |
protect_from_forgery | |
private | |
def require_user | |
unless @current_user | |
store_location | |
flash[:notice] = "You must be logged in to access this page" | |
redirect_to login_url | |
return false | |
end | |
end | |
def require_no_user | |
if @current_user | |
store_location | |
flash[:notice] = "You must be logged out to access this page" | |
redirect_to logout_url | |
return false | |
end | |
end | |
def store_location | |
session[:return_to] = request.request_uri | |
end | |
def redirect_back_or_default(default) | |
redirect_to(session[:return_to] || default) | |
session[:return_to] = nil | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment