我有一个Post模型,它使用Twitter的activerecord信誉系统来跟踪投票:
Post模型:
has_reputation :votes, source: :user, aggregated_by: :sum我试图急于加载与索引页面上的所有帖子相关的声誉。在this之后,我尝试这样做:
Post.find_with_reputation(:votes, :all, { :conditions => ["post_id = ?", self.id] })执行此操作时,我得到以下错误:
undefined method `id' for #<PostsController:0x007f8560c88150>如果我将其简化为:
Post.find_with_reputation(:votes, :all)我在我的视图中看到以下错误:
undefined method `votes' for #<Post:0x007f8560a6b610>你知道我在哪里做错了吗?
发布于 2014-08-12 16:38:18
你可以这样用……
@all_videos = Video.includes(:user,:reputations,:tags,:comments).where("videos.user_id !=?",current_or_guest_user.id).paginate(:page =>params[:page], :per_page => 10).find_with_reputation(:views, :all, order: "views desc")包含使用ActiveRecordRelation进行快速加载的帮助
https://stackoverflow.com/questions/25254799
复制相似问题