Skip to content

Commit

Permalink
name cancan and cancancan in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
timoschilling committed Oct 10, 2014
1 parent 0c83cfe commit d15bcd5
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions docs/13-authorization-adapter.md
Expand Up @@ -174,22 +174,23 @@ end

Sub-classing `ActiveAdmin::AuthorizationAdapter` is fairly low level. Many times
it's nicer to have a simpler DSL for managing authorization. Active Admin
provides an adapter out of the box for [CanCan](https://github.com/ryanb/cancan).
provides an adapter out of the box for [CanCan](https://github.com/ryanb/cancan)
and [CanCanCan](https://github.com/CanCanCommunity/cancancan).

To use the CanCan adapter, simply update the configuration in the Active Admin
initializer:

```ruby
config.authorization_adapter = ActiveAdmin::CanCanAdapter
```

You can also specify a method to be called on unauthorized access. This is necessary
in order to prevent a redirect loop that can happen if a user tries to access a page
they don't have permissions for (see [#2081](https://github.com/activeadmin/activeadmin/issues/2081)).

```ruby
config.on_unauthorized_access = :access_denied
```
```

The method `access_denied` would be defined in `application_controller.rb`. Here is one
example that redirects the user from the page they don't have permission to
Expand All @@ -199,7 +200,7 @@ also displays the error message in the browser:
```ruby
class ApplicationController < ActionController::Base
protect_from_forgery

def access_denied(exception)
redirect_to admin_organizations_path, :alert => exception.message
end
Expand All @@ -213,8 +214,8 @@ changed from the initializer:
config.cancan_ability_class = "MyCustomAbility"
```

Now you can simply use CanCan the way that you would expect and Active Admin
will use it for authorization:
Now you can simply use CanCan or CanCanCan the way that you would expect and
Active Admin will use it for authorization:

```ruby
# app/models/ability.rb
Expand All @@ -231,7 +232,7 @@ class Ability
end
```

To view more details about the CanCan API, visit [https://github.com/ryanb/cancan](https://github.com/ryanb/cancan).
To view more details about the API's, visit project pages of [CanCan](https://github.com/ryanb/cancan) and [CanCanCan](https://github.com/CanCanCommunity/cancancan).

## Using the Pundit Adapter

Expand Down

0 comments on commit d15bcd5

Please sign in to comment.