Skip to content
This repository was archived by the owner on Oct 18, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/2.0/authorization.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,18 @@ end

Now, Avo will use `avo_index?` instead of `index?` to manage the **Index** view authorization.

## Using custom policies

By default, Avo will infer the policy from the model of the resource object. If you wish to use a different policy for a given resource, you can specify it directly in the resource like so:

```ruby
class PhotoCommentResource < Avo::BaseResource
self.model_class = ::Comment
self.authorization_policy = PhotoCommentPolicy
# ...
end
```

## Raise errors when policies are missing

The default behavior of Avo is to silently allow missing policies for resources. So, if you have a `User` model and a `UserResource` but don't have a `UserPolicy`, Avo will not raise errors regarding missing policies and authorize that resource.
Expand Down
10 changes: 10 additions & 0 deletions src/2.0/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,16 @@ end
class Avo::SpreeStoresController < Avo::ResourcesController
end
```
## Custom policy

By default, Avo will infer the policy from the model of the resource object. If you wish to use a different policy for a given resource, you can specify it directly like so:

```ruby
# app/avo/resources/photo_comment_resource.rb
class PhotoCommentResource < Avo::BaseResource
self.authorization_policy = PhotoCommentPolicy
end
```

## Devise password optional

Expand Down