i think use named_scope is not elegant way. use class method? no idea.you
can give me your sample proj.i can test this way.

2009/12/2 Jeff Blasius <[email protected]>

> How would I write a named_scope that checks if the parent has at least
> one associated child?
>
> For example,
> class Post < ActiveRecord::Base
>  has many :comments
>
>  named_scope :commented_on, :conditions => "comments.count > 0"
>
>
> class Comment < ActiveRecord::Base
>  belongs_to :post
>
>
>
> Thanks,
>            jeff
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<rubyonrails-talk%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
>


-- 
tommy xiao
E-mail: xiaods(AT)gmail.com

--

You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.


Reply via email to