调用某些帖子的所有评论

| 我正在使用Rails 2.3.9应用程序,在这种情况下,帖子为
workouts
。我正在尝试为接下来的
workouts
获取所有
comments
@workouts = Workout.today_only.all(:include => {:user => :memberships}, :conditions => [\"workouts.public = \'1\' AND memberships.box_id = ?\", @box.id], :order => \"workouts.created_at DESC\")
我的关联是正确的:
Workout has_many :comments
Comment belongs_to :workout
我如何获得at5ѭ订购的特定锻炼的评论列表? 注意:“ 6”是named_scope,如果相关,我可以发布代码。     
已邀请:
在锻炼模型中,添加:
has_many :comments, :order => \'created_at DESC\'
那么您可以执行以下操作:
Workout.today_only.all(:include => [:comments, {:user => :memberships}], ...
    

要回复问题请先登录注册