1
视频表有列votes_count,我需要找到下一个流行的视频。我写了类似下面的内容,但没有帮助。任何帮助将不胜感激。找到下一个对象
@video = Video.find(1)
@next_video = Video.where("votes_count >= ? AND id != ?", @video.votes_count, @video.id).order("votes_count").first
视频表有列votes_count,我需要找到下一个流行的视频。我写了类似下面的内容,但没有帮助。任何帮助将不胜感激。找到下一个对象
@video = Video.find(1)
@next_video = Video.where("votes_count >= ? AND id != ?", @video.votes_count, @video.id).order("votes_count").first
@video = Video.find(1)
@next_video = Video.where("id != ?", @video.id).order("votes_count DESC").first
@video = Video.find(1)
@next_video = Video.where("votes_count > ? OR (votes_count = ? AND id > ?)", @video.votes_count, @video.votes_count, @video.id).order("votes_count").order("id").first
我把下一个视频链接视频的每个展示页面,它已经开始递归。 – rails101 2011-04-20 09:57:51
嘿,如果你有任何问题证明你的代码有错误。为什么它开始递归?你在哪里得到你的@next_video等。如果你做得对 - 它应该工作得很好。 – fl00r 2011-04-20 10:22:15