有没有办法从关联中急切加载named_scope?
我有我的文章模型:
class Article < ActiveRecord::Base has_many :comments end
和我的评论模型:
class Comment < ActiveRecord::Base belongs_to :article named_scope :approved, :conditions => { :approved => true } named_scope :unapproved, :conditions => { :approved => false } end
我可以急切地加载文章的所有评论:
@article = Article.find(params[:id], :include => :comments)
我怎样才能这样做,但仅限于批准的评论?