Documented hashie_rails.
This commit is contained in:
parent
80a8f11a78
commit
41e6c676e1
10
README.md
10
README.md
|
@ -236,15 +236,7 @@ p.trick # => NoMethodError
|
|||
|
||||
### Mash and Rails 4 Strong Parameters
|
||||
|
||||
If you're using [Rails 4 strong parameters](http://edgeguides.rubyonrails.org/action_controller_overview.html#strong-parameters), you will get a [ForbiddenAttributesProtection](https://github.com/rails/strong_parameters/blob/master/lib/active_model/forbidden_attributes_protection.rb) exceptions when mass-assigning attributes.
|
||||
|
||||
To allow mass assignment, add the following initializer in config/initializers/mash.rb. This prevents Mash from responding to `:permitted?` and therefore triggering this behavior in [ForbiddenAttributesProtection](https://github.com/rails/strong_parameters/blob/master/lib/active_model/forbidden_attributes_protection.rb).
|
||||
|
||||
```ruby
|
||||
class Mash
|
||||
include Hashie::Extensions::Mash::ActiveModel
|
||||
end
|
||||
```
|
||||
To enable compatibility with Rails 4 use the ['hashie\_rails' gem](http://rubygems.org/gems/hashie_rails).
|
||||
|
||||
## Trash
|
||||
|
||||
|
|
12
UPGRADING.md
12
UPGRADING.md
|
@ -5,17 +5,15 @@ Upgrading Hashie
|
|||
|
||||
#### Compatibility with Rails 4 Strong Parameters
|
||||
|
||||
Version 2.1 introduced support to prevent default Rails 4 mass-assignment protection behavior. This was [issue #89](https://github.com/intridea/hashie/issues/89), resolved in [#104](https://github.com/intridea/hashie/pull/104). In version 2.2 this behavior has been removed in [#147](https://github.com/intridea/hashie/pull/147) in favor of a mixin.
|
||||
Version 2.1 introduced support to prevent default Rails 4 mass-assignment protection behavior. This was [issue #89](https://github.com/intridea/hashie/issues/89), resolved in [#104](https://github.com/intridea/hashie/pull/104). In version 2.2 this behavior has been removed in [#147](https://github.com/intridea/hashie/pull/147) in favor of a mixin and extracted into a separate gem in 3.0.
|
||||
|
||||
To enable 2.1 compatible behavior, add the following initializer in config/initializers/mash.rb. This prevents Mash from responding to `:permitted?` and therefore triggering this behavior in [ForbiddenAttributesProtection](https://github.com/rails/strong_parameters/blob/master/lib/active_model/forbidden_attributes_protection.rb).
|
||||
To enable 2.1 compatible behavior, use the ['hashie\_rails' gem](http://rubygems.org/gems/hashie_rails).
|
||||
|
||||
```ruby
|
||||
class Mash
|
||||
include Hashie::Extensions::Mash::ActiveModel
|
||||
end
|
||||
```bash
|
||||
gem 'hashie_rails'
|
||||
```
|
||||
|
||||
See [Mash and Rails 4 Strong Parameters](README.md#mash-and-rails-4-strong-parameters) for more details.
|
||||
See [#154](https://github.com/intridea/hashie/pull/154) and [Mash and Rails 4 Strong Parameters](README.md#mash-and-rails-4-strong-parameters) for more details.
|
||||
|
||||
#### Key Conversions in Hashie::Dash and Hashie::Trash
|
||||
|
||||
|
|
Loading…
Reference in New Issue