我正在使用Rails 2.3.9应用程序,在这种情况下帖子是workouts
。我正在尝试获得以下所有comments
workouts
。打电话给某些帖子的所有评论
@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
我该如何获得在对created_at DESC
下令那些specifc锻炼评论列表?
注意:today_only
是一个named_scope,如果它是相关的,我可以发布代码。
我建议创造那些条件更named_scopes和包括。现在你的代码在同一行上有几个抽象层次。 – kikito 2011-04-25 18:29:55
是的,我同意。只需要做到这一点。 – bgadoci 2011-04-26 02:24:15