mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Added nested attributes example for README (#4434)
This commit is contained in:
parent
2458334de6
commit
f8c1ee0f90
1 changed files with 15 additions and 1 deletions
16
README.md
16
README.md
|
@ -216,7 +216,21 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
```
|
||||
|
||||
The above works for any additional fields where the parameters are simple scalar types. If you have nested attributes (say you're using `accepts_nested_attributes_for`), then you will need to tell devise about those nestings and types. Devise allows you to completely change Devise defaults or invoke custom behaviour by passing a block:
|
||||
The above works for any additional fields where the parameters are simple scalar types. If you have nested attributes (say you're using `accepts_nested_attributes_for`), then you will need to tell devise about those nestings and types:
|
||||
|
||||
```ruby
|
||||
class ApplicationController < ActionController::Base
|
||||
before_action :configure_permitted_parameters, if: :devise_controller?
|
||||
|
||||
protected
|
||||
|
||||
def configure_permitted_parameters
|
||||
devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name, address_attributes: [:country, :state, :city, :area, :postal_code]])
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
Devise allows you to completely change Devise defaults or invoke custom behaviour by passing a block:
|
||||
|
||||
To permit simple scalar values for username and email, use this
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue