Skip to content
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

Mass-assignment issue with 0.1.8 #50

Closed
soffes opened this issue Aug 11, 2012 · 5 comments
Closed

Mass-assignment issue with 0.1.8 #50

soffes opened this issue Aug 11, 2012 · 5 comments

Comments

@soffes
Copy link
Contributor

soffes commented Aug 11, 2012

I upgraded from 0.1.7 to 0.1.8 and I'm not getting a mass-assignment error. With 0.1.7 I get

DEPRECATION WARNING: update_attribute is deprecated and will be removed in Rails 4. If you want to skip mass-assignment protection, callbacks, and modifying updated_at, use update_column. If you do want those things, use update_attributes. (called from move_to at /Users/samsoffes/Code/cheddarapp.com/app/models/task.rb:82)

with all tests green. Under 0.1.8 this goes away (yay! ) but now I get this:

ActiveModel::MassAssignmentSecurity::Error: Can't mass-assign protected attributes: position
    /Users/samsoffes/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activemodel-3.2.7/lib/active_model/mass_assignment_security/sanitizer.rb:48:in `process_removed_attributes'
    /Users/samsoffes/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activemodel-3.2.7/lib/active_model/mass_assignment_security/sanitizer.rb:20:in `debug_protected_attribute_removal'
    /Users/samsoffes/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activemodel-3.2.7/lib/active_model/mass_assignment_security/sanitizer.rb:12:in `sanitize'
    /Users/samsoffes/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activemodel-3.2.7/lib/active_model/mass_assignment_security.rb:230:in `sanitize_for_mass_assignment'
    /Users/samsoffes/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/attribute_assignment.rb:75:in `assign_attributes'
    /Users/samsoffes/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/persistence.rb:227:in `block in update_attributes!'
    /Users/samsoffes/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/transactions.rb:295:in `block in with_transaction_returning_status'
    /Users/samsoffes/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
    /Users/samsoffes/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/transactions.rb:208:in `transaction'
    /Users/samsoffes/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
    /Users/samsoffes/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/persistence.rb:226:in `update_attributes!'
    /Users/samsoffes/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/acts_as_list-0.1.8/lib/acts_as_list/active_record/acts/list.rb:233:in `assume_bottom_position'
    /Users/samsoffes/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/acts_as_list-0.1.8/lib/acts_as_list/active_record/acts/list.rb:121:in `block in move_to_bottom'
    /Users/samsoffes/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
    /Users/samsoffes/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/activerecord-3.2.7/lib/active_record/transactions.rb:208:in `transaction'
    /Users/samsoffes/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/acts_as_list-0.1.8/lib/acts_as_list/active_record/acts/list.rb:119:in `move_to_bottom'
...
@robinboening
Copy link

You need to make :position accessible in your model that acts as list, that will fix it.
http://api.rubyonrails.org/classes/ActiveModel/MassAssignmentSecurity/ClassMethods.html

@soffes
Copy link
Contributor Author

soffes commented Aug 11, 2012

I don't want to make it accessible and I didn't have to in the past. Could you add support for non accessible position like there use to be?

@swanandp
Copy link
Collaborator

The move to update_attributes instead of update_attribute caused this. We
need to use []= or position=

On Sat, Aug 11, 2012 at 9:18 PM, Sam Soffes notifications@github.comwrote:

I don't want to make it accessible and I didn't have to in the past. Could
you add support for non accessible position like there use to be?


Reply to this email directly or view it on GitHubhttps://github.com//issues/50#issuecomment-7667743.

@swanandp
Copy link
Collaborator

@soffes : I think with 094b39c, this is no longer an issue. Can you please check?

@swanandp
Copy link
Collaborator

This issue is now fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants