Module: HasRoles::InstanceMethods

Defined in:
lib/has_roles.rb

Instance Method Summary (collapse)

Instance Method Details

- (Boolean) authorized_for?(options = '')

Checks whether this user is authorized to access the given url.

Examples

user = User.find(1)
user.authorized_for?(:controller => 'admin/messages')
user.authorized_for?(:controller => 'admin/messages', :action => 'destroy')
user.authorized_for?('admin/messages')
user.authorized_for?('http://localhost:3000/admin/messages')

Returns:

  • (Boolean)


30
31
32
# File 'lib/has_roles.rb', line 30

def authorized_for?(options = '')
  !Permission.restricts?(options) || roles.authorized_for(options).exists?
end