Created
August 1, 2014 15:35
-
-
Save LukeHackett/7a200afae0645a189a0b to your computer and use it in GitHub Desktop.
yolo
This file contains hidden or 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
def require_user | |
unless current_user | |
store_location | |
flash[:danger] = "You must be logged in to access this page" | |
redirect_to login_path | |
return false | |
end | |
end | |
def require_no_user | |
if current_user | |
store_location | |
flash[:danger] = "You must be logged out to access this page" | |
redirect_to logout_path | |
return false | |
end | |
end | |
def store_location | |
session[:return_to] = request.original_url | |
end | |
def redirect_back_or_default(default) | |
redirect_to(session[:return_to] || default) | |
session[:return_to] = nil | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment