Skip to content

Commit a11e9d4

Browse files
committed
Merge pull request activeadmin#3016 from shekibobo/docs/controller-override-permitted-params
Add docs about permit_params and overriding controller actions
2 parents 3fb7f03 + 3c058eb commit a11e9d4

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

docs/2-resource-customization.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,25 @@ ActiveAdmin.register Post do
5353
end
5454
```
5555

56+
The `permit_params` call creates a method called `permitted_params`. You should use this method when overriding `create` or `update` actions:
57+
58+
```ruby
59+
ActiveAdmin.register Post do
60+
controller do
61+
def create
62+
# Good
63+
@post = Post.new(permitted_params)
64+
# Bad
65+
@post = Post.new(params[:post])
66+
67+
if @post.save
68+
# ...
69+
end
70+
end
71+
end
72+
end
73+
```
74+
5675
## Disabling Actions on a Resource
5776

5877
All CRUD actions are enabled by default. These can be disabled for a given resource:

0 commit comments

Comments
 (0)