问题描述
我正在通过 Michael Hartl 的精彩Ruby on Rails 教程学习 Rails.我在 第 3.2.2 节(测试驱动开发) 中,我需要在其中运行以下命令为我的 Rails 项目运行 rspec 测试:
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 command to run the rspec tests for my Rails project:
bundle exec rspec spec/
但它不起作用.相反,我收到此错误:
But it doesn't work. Instead I get this error:
/Users/mh/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/
activerecord-3.1.3/lib/active_record/base.rb:1088:in `method_missing':
undefined method `mass_assignment_sanitizer=' for
ActiveRecord::Base:Class (NoMethodError)
我尝试重新安装 rspec
和 更改我的 Gemfile,但没有任何方法可以缓解未定义的方法错误!
I've tried reinstalling rspec
and changing my Gemfile, but nothing appeases the undefined method error!
推荐答案
您是否从 Rails 3.2 RC1 降级?从 development.rb 中注释掉以下两行:
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
这篇关于未定义的方法 `mass_assignment_sanitizer=' 用于 ActiveRecord::Base:Class (NoMethodError)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!