Created
February 14, 2013 22:05
-
-
Save m3talsmith/4956828 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 ProtectedController << ApplicationController | |
before_filter :force_user | |
def index | |
end | |
private | |
def force_user | |
unless session[:user_id] | |
session[:redirect_url] = request.fullpath | |
redirect_to new_sessions_path | |
end | |
end | |
end |
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 SessionsController << ApplicationController | |
def create | |
session[:user_id] = User.first.id | |
redirect_to session[:redirect_url] ? session[:redirect_to] : root_path | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment