New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom engine generator should create attributes whitelist now that rails requires you to do so #1578
Comments
hm this was done already https://github.com/resolve/refinerycms/blob/2-0-stable/core/lib/generators/refinery/engine/templates/app/models/refinery/namespace/singular_name.rb#L8 Can you try putting in your Gemfile: gem 'refinerycms', :git => 'git://github.com/resolve/refinerycms.git', :branch => '2-0-stable' bundle and generate the engine again.. does it still need |
It 'almost' fixes the problem. I ran the following code:
And here is what refinery generated for me:
As you can see, attr_accessible is set, but only for the first attribute (and position), so I still get the mass assignment error. |
Imo user should take care of specifying which attributes he want's to allow to be mass-assigned. Refinery should not guess those attributes. For example what happens when I generate an engine with admin boolean attribute which I clearly don't want to be mass-assigned? I would have to go into model and delete it from attr_accessible ... |
We should have best practice by default. Plus, this code's already in our codebase.. |
@parndt what's best practice? |
To make it work out of the box |
@parndt ^ |
Add all generated attributes to attr_accessible whitelist. #1578.
Conflicts: core/lib/generators/refinery/engine/templates/app/models/refinery/namespace/singular_name.rb
Rails 3.2.3 expects you to white-list your model's attributes before you can write to the db.
If you create a custom engine using
rails g refinery:engine article attr1 attr2 attr3
, then you will not be able save any records until you set attr_accessible in your model. Rails throws a mass-assignment error until you do. You will also need to include the refinery-generatedposition
field in your whitelist.The text was updated successfully, but these errors were encountered: