Ruby on rails 推特声誉系统Gem可以';t分配受保护的属性
我跟着火车走 在我的用户模型上,我有:Ruby on rails 推特声誉系统Gem可以';t分配受保护的属性,ruby-on-rails,ruby,ruby-on-rails-3,rubygems,Ruby On Rails,Ruby,Ruby On Rails 3,Rubygems,我跟着火车走 在我的用户模型上,我有: has_many :evaluations, class_name: "RSEvaluation", as: :source has_reputation :votes, source: {reputation: :votes, of: :articles}, aggregated_by: :sum def voted_for?(article) evaluations.where(target_type: article.class, targe
has_many :evaluations, class_name: "RSEvaluation", as: :source
has_reputation :votes, source: {reputation: :votes, of: :articles}, aggregated_by: :sum
def voted_for?(article)
evaluations.where(target_type: article.class, target_id: article.id).present?
end
第一条:
has_reputation :votes, source: :user, aggregated_by: :sum
及物品控制员:
def vote
value = params[:type] == "up" ? 1 : -1
@article = article.find(params[:id])
@article.add_or_update_evaluation(:votes, value, current_user)
redirect_to :back
end
但当我去投票时:
无法批量分配受保护的属性:声誉、名称、值、,
源id、源类型、目标id、目标类型
有人对此gem有相同的问题吗?批量分配错误表明您正在Rails 3中使用声誉gem。您需要将gem降级到版本2 在文件中,指定版本2
# Gemfile
gem 'activerecord-reputation-system', '~> 2.0', require: 'reputation_system'
然后更新你的包
bundle update activerecord-reputation-system
抱歉@dimakura,我没听清你的问题