Created
March 14, 2011 18:20
-
-
Save guillermo/869582 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
module RequireLoggedUser | |
protected | |
def require_logged_user! | |
before_filter do | |
return true if current_user.present? | |
# if the method hasn't returned, there is no user logged in! | |
# flash a warning and redirect the user to the log in page | |
flash[:warning] = "You must log in before proceeding!" | |
redirect_to new_user_session_path and return | |
end | |
def self.extend_object(controller) | |
super | |
controller.send(:require_logged_user!) | |
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 StoreCheckoutsController < ApplicationController | |
extend RequireLoggedUser | |
... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment