deprecated_mass_assignment_security.rb:14:在`attr_accessible'[投票宝石] [rails 4]

时间:2013-07-24 18:38:52

标签: ruby-on-rails ruby-on-rails-3 ruby-on-rails-4

所以,在运行时

[leap_staging]$rails g reputation_system

在包含gem'activerecord-reputation-system'之后,在我的Gemfile中输入'reputation_system'我得到以下错误:

/usr/local/rvm/gems/ruby-2.0.0-p195/gems/activemodel-4.0.0/lib/active_model/deprecated_mass_assignment_security.rb:14:in `attr_accessible': `attr_accessible` is extracted out of Rails into a gem. Please use new recommended protection model for params(strong_parameters) or add `protected_attributes` to your Gemfile to use old one. (RuntimeError)
    from /usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-reputation-system-2.0.2/lib/reputation_system/models/evaluation.rb:25:in `<class:Evaluation>'
    from /usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-reputation-system-2.0.2/lib/reputation_system/models/evaluation.rb:18:in `<module:ReputationSystem>'
    from /usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-reputation-system-2.0.2/lib/reputation_system/models/evaluation.rb:17:in `<top (required)>'
    from /usr/local/rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
    from /usr/local/rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
    from /usr/local/rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
    from /usr/local/rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
    from /usr/local/rvm/gems/ruby-2.0.0-p195/gems/activerecord-reputation-system-2.0.2/lib/reputation_system.rb:25:in `<top (required)>'
    from /usr/local/rvm/gems/ruby-2.0.0-p195@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
    from /usr/local/rvm/gems/ruby-2.0.0-p195@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
    from /usr/local/rvm/gems/ruby-2.0.0-p195@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
    from /usr/local/rvm/gems/ruby-2.0.0-p195@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
    from /usr/local/rvm/gems/ruby-2.0.0-p195@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
    from /usr/local/rvm/gems/ruby-2.0.0-p195@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
    from /usr/local/rvm/gems/ruby-2.0.0-p195@global/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
    from /Users/apane/Downloads/leap_staging/leap_staging/config/application.rb:7:in `<top (required)>'
    from /usr/local/rvm/gems/ruby-2.0.0-p195/gems/railties-4.0.0/lib/rails/commands.rb:44:in `require'
    from /usr/local/rvm/gems/ruby-2.0.0-p195/gems/railties-4.0.0/lib/rails/commands.rb:44:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

我很清楚,这必须与Rails 4和新的Strong Params一起使用。但是,我希望得到这个工作。那么,如果我甚至无法生成文件,我怎么能让它工作或将其转换为strong_params?

如果需要,请在此处查看完整的应用程序以便于故障排除:www.github.com/apane/leap(不包括宝石)

2 个答案:

答案 0 :(得分:1)

您是否尝试将protected_attributes Gem添加到您的Gemfile中,如消息所示?

答案 1 :(得分:0)

activerecord-reputation-system gem现在支持Rails 4(从3.0版开始)。