Created
September 2, 2009 21:37
-
-
Save vinibaggio/179976 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
def self.allow(roles, options = {}) | |
class_eval do | |
def check_permission | |
# Insert your application logic here | |
if current_user.nil? or !current_user.roles.exists?(:id => roles) | |
flash[:notice] = "Go away!" | |
return check_and_redirect_to("/login") | |
end | |
end | |
end | |
before_filter :check_permission, options | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment