Skip to content
This repository has been archived by the owner on Jan 4, 2021. It is now read-only.

Commit

Permalink
Implements access_allowed_to_controller?
Browse files Browse the repository at this point in the history
  • Loading branch information
alxberardi committed Sep 15, 2015
1 parent 4d41552 commit e4fc771
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/right_on/action_controller_extensions.rb
Expand Up @@ -15,6 +15,18 @@ def verify_rights
access_allowed?(controller_action_options) || permission_denied
end

# Checks the access privilege for a controller
def access_allowed_to_controller?(controller)
controller_class = "#{controller.to_s.camelcase}Controller".safe_constantize

# Handle inheritance of rights
if controller_class && controller_class.rights_from.present?
controller = controller_class.rights_from.to_s
end

access_allowed?(controller)
end

# Checks the access privilege of the user and returns true or false
def access_allowed?(opts={})
if opts.is_a?(String)
Expand Down

0 comments on commit e4fc771

Please sign in to comment.