Can't mass-assign protected attributes: version on db:migrate (rails master) #4897

Closed
slbug opened this Issue Feb 5, 2012 · 1 comment

Comments

Projects
None yet
2 participants
Contributor

slbug commented Feb 5, 2012

whitelist_attributes set to true

one pending migration (model product with one field title)

trace:

** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
** Execute db:migrate
==  CreateProducts: migrating =================================================
-- create_table(:products)
NOTICE:  CREATE TABLE will create implicit sequence "products_id_seq" for serial column "products.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "products_pkey" for table "products"
   -> 0.0573s
-- add_index(:products, :title, {:unique=>true})
   -> 0.0414s
==  CreateProducts: migrated (0.0989s) ========================================

rake aborted!
An error has occurred, this and all later migrations canceled:

Can't mass-assign protected attributes: version
~/.rvm/gems/ruby-1.9.3-p0/bundler/gems/rails-956fb811cede/activemodel/lib/active_model/mass_assignment_security/sanitizer.rb:49:in `process_removed_attributes'
~/.rvm/gems/ruby-1.9.3-p0/bundler/gems/rails-956fb811cede/activemodel/lib/active_model/mass_assignment_security/sanitizer.rb:15:in `debug_protected_attribute_removal'
~/.rvm/gems/ruby-1.9.3-p0/bundler/gems/rails-956fb811cede/activemodel/lib/active_model/mass_assignment_security/sanitizer.rb:7:in `sanitize'
~/.rvm/gems/ruby-1.9.3-p0/bundler/gems/rails-956fb811cede/activemodel/lib/active_model/mass_assignment_security.rb:230:in `sanitize_for_mass_assignment'
~/.rvm/gems/ruby-1.9.3-p0/bundler/gems/rails-956fb811cede/activerecord/lib/active_record/attribute_assignment.rb:75:in `assign_attributes'
~/.rvm/gems/ruby-1.9.3-p0/bundler/gems/rails-956fb811cede/activerecord/lib/active_record/core.rb:175:in `initialize'
~/.rvm/gems/ruby-1.9.3-p0/bundler/gems/rails-956fb811cede/activerecord/lib/active_record/validations.rb:39:in `new'
~/.rvm/gems/ruby-1.9.3-p0/bundler/gems/rails-956fb811cede/activerecord/lib/active_record/validations.rb:39:in `create!'
~/.rvm/gems/ruby-1.9.3-p0/bundler/gems/rails-956fb811cede/activerecord/lib/active_record/migration.rb:777:in `record_version_state_after_migrating'
~/.rvm/gems/ruby-1.9.3-p0/bundler/gems/rails-956fb811cede/activerecord/lib/active_record/migration.rb:713:in `block (2 levels) in migrate'
~/.rvm/gems/ruby-1.9.3-p0/bundler/gems/rails-956fb811cede/activerecord/lib/active_record/migration.rb:792:in `block in ddl_transaction'
~/.rvm/gems/ruby-1.9.3-p0/bundler/gems/rails-956fb811cede/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:190:in `transaction'
~/.rvm/gems/ruby-1.9.3-p0/bundler/gems/rails-956fb811cede/activerecord/lib/active_record/transactions.rb:208:in `transaction'
~/.rvm/gems/ruby-1.9.3-p0/bundler/gems/rails-956fb811cede/activerecord/lib/active_record/migration.rb:792:in `ddl_transaction'
~/.rvm/gems/ruby-1.9.3-p0/bundler/gems/rails-956fb811cede/activerecord/lib/active_record/migration.rb:711:in `block in migrate'
~/.rvm/gems/ruby-1.9.3-p0/bundler/gems/rails-956fb811cede/activerecord/lib/active_record/migration.rb:707:in `each'
~/.rvm/gems/ruby-1.9.3-p0/bundler/gems/rails-956fb811cede/activerecord/lib/active_record/migration.rb:707:in `migrate'
~/.rvm/gems/ruby-1.9.3-p0/bundler/gems/rails-956fb811cede/activerecord/lib/active_record/migration.rb:574:in `up'
~/.rvm/gems/ruby-1.9.3-p0/bundler/gems/rails-956fb811cede/activerecord/lib/active_record/migration.rb:552:in `migrate'
~/.rvm/gems/ruby-1.9.3-p0/bundler/gems/rails-956fb811cede/activerecord/lib/active_record/railties/databases.rake:152:in `block (2 levels) in '
~/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
~/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
~/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
~/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
~/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
~/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
~/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
~/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
~/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
~/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
~/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
~/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
~/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
~/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
~/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
~/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
~/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
~/.rvm/gems/ruby-1.9.3-p0/gems/rake-0.9.2.2/bin/rake:33:in `'
~/.rvm/gems/ruby-1.9.3-p0/bin/rake:19:in `load'
~/.rvm/gems/ruby-1.9.3-p0/bin/rake:19:in `'
Tasks: TOP => db:migrate

Member

vijaydev commented Feb 6, 2012

Fixed in #4900.

vijaydev closed this Feb 6, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment