Undefined method `mass_assignment_sanitizer=' for ActiveRecord::Base:Class (NoMethodError)

前端 未结 2 1514
抹茶落季
抹茶落季 2020-12-15 17:43

I\'m learning Rails with the awesome Ruby on Rails Tutorial by Michael Hartl. I\'m on section 3.2.2 (Test Driven Development) in which I need to run the following c

相关标签:
2条回答
  • 2020-12-15 18:14

    Did you downgrade from Rails 3.2 RC1? Comment out the following two lines from your development.rb:

    config.active_record.mass_assignment_sanitizer = :strict
    config.active_record.auto_explain_threshold_in_seconds = 0.5
    
    0 讨论(0)
  • 2020-12-15 18:24

    While m818's answer will solve the problem, you might still get errors if you are tyring to use deprecated methods elsewhere in your code.

    I had the same problem, commenting out those lines got rid of some errors, but not all of them, anywhere I was using attr_accessible gave me the same error.

    It turned out to be the `active_record' gem that was updated to 4.0 when I didn't want it to. Since I'm using a Padrino app, I had to do this in the Gemfile:

    gem 'activerecord', '= 3.2.12', :require => "active_record"
    

    That solved all issues and I didn't have to comment out the lines in database.rb.

    0 讨论(0)
提交回复
热议问题