Ruby on rails activerecord信誉系统不工作
我做了一个小项目参考快速启动,但当我访问信誉值时,出现了一个错误 回答:声誉:平均评级 有人帮我吗 假设我们想在问答网站中跟踪用户业力,其中用户业力是提问技能和回答技能的总和。提问技巧是用户问题的投票总数,回答技巧是用户答案平均评分的总和。这可以定义如下:Ruby on rails activerecord信誉系统不工作,ruby-on-rails,Ruby On Rails,我做了一个小项目参考快速启动,但当我访问信誉值时,出现了一个错误 回答:声誉:平均评级 有人帮我吗 假设我们想在问答网站中跟踪用户业力,其中用户业力是提问技能和回答技能的总和。提问技巧是用户问题的投票总数,回答技巧是用户答案平均评分的总和。这可以定义如下: 尝试从应答模型中删除:as=>:author,并在初始化中设置:of=>:user的has\u声誉:avg\u评级。您应该发布更多代码。 NoMethodError: undefined method `to_sym' for nil:Nil
尝试从应答模型中删除:as=>:author,并在初始化中设置:of=>:user的has\u声誉:avg\u评级。您应该发布更多代码。
NoMethodError: undefined method `to_sym' for nil:NilClass
from /Users/Juo/.rvm/gems/ruby-2.0.0-p195/bundler/gems/activerecord-reputation-system-01197ad78cac/lib/reputation_system/models/reputation.rb:189:in `get_target_type_for_sti'
from /Users/Juo/.rvm/gems/ruby-2.0.0-p195/bundler/gems/activerecord-reputation-system-01197ad78cac/lib/reputation_system/models/reputation.rb:198:in `set_target_type_for_sti'
from /Users/Juo/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:377:in `_run__3152603553061474011__validation__callbacks'`
class User < ActiveRecord::Base
has_many :answers
has_many :questions
has_reputation :karma,
:source => [
{ :reputation => :questioning_skill, :weight => 0.8 },
{ :reputation => :answering_skill }]
has_reputation :questioning_skill,
:source => { :reputation => :votes, :of => :questions }
has_reputation :answering_skill,
:source => { :reputation => :avg_rating, :of => :answers }
end
class Answer < ActiveRecord::Base
belongs_to :user, :as => :author
has_reputation :avg_rating,
:source => :user,
:aggregated_by => :average,
:source_of => [{ :reputation => :answering_skill, :of => :author }]
end
class Question < ActiveRecord::Base
belongs_to :user
has_reputation :votes,
:source => :user
end