我正在使用Twitter的新activerecord-reputation-system gem,但它似乎没有在我的应用程序中注册。
我跑去安装(文档有拼写错误):
gem install activerecord-reputation-system && rails generate reputation_system && rake db:migrate
我已经将它包含在我的gemfile中并尝试直接从github中提取,以及重新启动我的本地服务器。错误如下:
ActionController :: RoutingError(未定义的方法
has_reputation' for #<Class:0x007fa7ed783ec0>): app/models/post.rb:18:in
' app / models / post.rb:1:in<top (required)>' app/controllers/posts_controller.rb:1:in
'
当我尝试使用此代码向帖子添加投票时:
class Post < ActiveRecord::Base
belongs_to :user
has_reputation :votes,
:source => :user,
:aggregated_by => :sum
end
当我尝试使用相同的代码向用户添加投票时:
undefined method `has_reputation' for #<Class:0x007fa7efb70388>
app/models/user.rb:17:in `<class:User>'
app/models/user.rb:1:in `<top (required)>'
config/routes.rb:4:in `block in <top (required)>'
config/routes.rb:1:in `<top (required)>'
This error occurred while loading the following files:
/Users/username/appname/config/routes.rb
routes.rb,第4行:
devise_for:users,:controllers =&gt; {:omniauth_callbacks =&gt; “users / omniauth_callbacks”}
有什么想法吗?
答案 0 :(得分:4)
您的应用应该需要reputation_system
。您可以通过添加到Gemfile
:
gem 'activerecord-reputation-system', :require => 'reputation_system'
更新:从版本2.0.0
开始,您不再需要reputation_system
了:
gem 'activerecord-reputation-system'