class Picture < ActiveRecord::Base
has_many :most_recent_comments, :class_name => 'Comment', :order => 'id DESC', :limit => 10
end
Picture.find(:first, :include => :most_recent_comments).most_recent_comments # => returns all associated comments.
Namedscoped
最新推荐文章于 2011-04-28 17:15:27 发布