activerecord-reputation-system gem阻止保存新对象

时间:2014-11-06 17:04:49

标签: activerecord

我正在关注添加Active Record Reputation System的railscast。 (http://railscasts.com/episodes/364-active-record-reputation-system)我有一个模特衬衫,我希望用户可以投票。我用以下代码更新了我的gemfile:

gem 'activerecord-reputation-system', require: 'reputation_system'

我运行了一个bundle install并重新启动了服务器。现在,当我尝试创建一件新衬衫时,我收到一条通知,即使我输入了该衬衫,该衬衫仍然缺少一个名字,而且我无法创建一件新衬衫。一旦我删除了宝石并运行捆绑安装,一切都恢复正常,我可以创建一件没有问题的衬衫。知道这里发生了什么吗?

以下是日志:

Started POST "/shirts" for 127.0.0.1 at 2014-11-06 11:59:18 -0500
Processing by ShirtsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"eiVOinXgtMUoPGwI5IK3n4GFGWv/0xA8ZdD6b6Pvgko=", "shirt"=>{"name"=>"asfas", "category"=>"Startup", "description"=>"", "url"=>"", "approved"=>"0"}, "commit"=>"Submit Changes"}
WARNING: Can't mass-assign protected attributes for Shirt: name, category, url, approved, description
    app/controllers/shirts_controller.rb:11:in `create'
   (0.2ms)  begin transaction
   (0.1ms)  rollback transaction
  Rendered admins/new_shirt.html.erb within layouts/application (5.6ms)
  User Load (0.3ms)  SELECT  "users".* FROM "users"  WHERE "users"."id" = 3 LIMIT 1
Completed 200 OK in 318ms (Views: 232.8ms | ActiveRecord: 1.2ms)


Started GET "/assets/sessions.css?body=1" for 127.0.0.1 at 2014-11-06 11:59:18 -0500


Started GET "/assets/shirts.css?body=1" for 127.0.0.1 at 2014-11-06 11:59:18 -0500


Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2014-11-06 11:59:18 -0500


Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2014-11-06 11:59:18 -0500


Started GET "/assets/custom.css?body=1" for 127.0.0.1 at 2014-11-06 11:59:18 -0500


Started GET "/assets/users.css?body=1" for 127.0.0.1 at 2014-11-06 11:59:18 -0500


Started GET "/assets/bootstrap.js?body=1" for 127.0.0.1 at 2014-11-06 11:59:18 -0500


Started GET "/assets/turbolinks.js?body=1" for 127.0.0.1 at 2014-11-06 11:59:18 -0500


Started GET "/assets/sessions.js?body=1" for 127.0.0.1 at 2014-11-06 11:59:18 -0500


Started GET "/assets/shirts.js?body=1" for 127.0.0.1 at 2014-11-06 11:59:18 -0500


Started GET "/assets/users.js?body=1" for 127.0.0.1 at 2014-11-06 11:59:18 -0500


Started GET "/assets/admins.js?body=1" for 127.0.0.1 at 2014-11-06 11:59:18 -0500


Started GET "/assets/admins.css?body=1" for 127.0.0.1 at 2014-11-06 11:59:18 -0500


Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2014-11-06 11:59:18 -0500


Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2014-11-06 11:59:18 -0500 

2 个答案:

答案 0 :(得分:1)

使用以下gem解决了这个问题。

gem 'activerecord-reputation-system', github: 'NARKOZ/activerecord-reputation-system', branch: 'rails4'

答案 1 :(得分:0)

从版本3.0开始,activerecord-reputation-system支持Rails 4,并且在3.0.1版本中修复了该错误