Skip to content

Instantly share code, notes, and snippets.

@vinibaggio
Created September 2, 2009 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vinibaggio/179976 to your computer and use it in GitHub Desktop.
Save vinibaggio/179976 to your computer and use it in GitHub Desktop.
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