Skip to content

Commit b821e88

Browse files
improves docs for callback
1 parent 06af5b5 commit b821e88

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

docs/features/callbacks.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
# Callbacks
22

33
You can use the callbacks in the controller to add some logic before, around or after `set_resource`
4-
or `set_parent_resource`:
4+
, `set_parent_resource` or `set_all_resources`:
5+
6+
- The `set_resource` method is called in [:show, :update, :destroy] actions
7+
- The `set_parent_resource` method is called in all actions if you are using nested resources
8+
- The `set_all_resources` method is called in [:index] actions
59

610
```ruby
711
# frozen_string_literal: true
812

913
class CarsController < RestApiGenerator::ResourceController
1014
after_set_resource :authorize_logic
15+
set_all_resources -> { @resources = authorized_resource(@resources) }
1116

1217
def authorize_logic
1318
# Custom authorization logic

0 commit comments

Comments
 (0)