为游戏预告片制作一个网站,在首页上我根据游戏的类别组织游戏,所以我最终这样做了(rails):
def index
@newGames = Game.order("created_at DESC").limit(3)
@casualGames = Game.where("category = 'casual'").limit(9)
@actionGames = Game.where("category = 'action'").limit(8)
@strategyGames = Game.where("category = 'strategy'").limit(9)
@adventureGames = Game.where("category = 'adventure'").limit(8)
@puzzleGames = Game.where("category = 'puzzle'").limit(9)
end
有没有办法完成同样的事情,但无需对 sable 表进行 6 个单独的查询?
谢谢