我正在實施activerecord-reputation-system gem,並且遇到了一個面向最受歡迎的文章的問題。Rails主動記錄聲望系統範圍/查詢問題
/articles_controller
def index
....
@loved_articles = Article.page(params[:page]).find_with_reputation(:votes, :all, {:order => 'votes DESC, created_at DESC'})
....
end
我打過電話.per(5)後的[:頁面])每(5)....但導軌給了我錯誤
/article model
def self.loved
find_with_reputation(:votes, :all, {:order => 'votes DESC'}).first(5)
end
的 「每」未定義的方法`「。 -
我會想象調用.first(5)可以調用它,但沒有任何事情發生 - 在我看來,循環只是咀嚼所有的文章。有任何想法嗎?
寫沒關係 - 我不使用分頁... – cpursley