每當我嘗試執行find_with_reputation
或count_with_reputation
方法時,都會收到以下錯誤消息。Rails - ActiveRecord聲譽系統作用域查詢問題
ArgumentError: Evaluations of votes must have scope specified
我的模型定義如下:
class Post < ActiveRecord::Base
has_reputation :votes,
:source => :user,
:scopes => [:up, :down]
的錯誤,當我試圖執行,例如提出了:
Post.find_with_reputation(:votes, :up)
或
Post.find_with_reputation(:votes, :up, { order: "likes" })
不幸的是, documentation對於如何解決這個錯誤並不是很清楚。這只是說的方法如下,應執行:
ActiveRecord::Base.find_with_reputation(:reputation_name, :scope, :find_options)
在車型沒有作用域與方法,如ActiveRecord的信譽系統運作良好:
User.find_with_reputation(:karma, :all)
任何幫助將非常感激。