On Thu, Jan 15, 2009 at 1:29 PM, Tom M <thomas.mack...@gmail.com> wrote:
> > Patrick, > > Thanks... I checked again and the example I posted was a bit off of my > real example, which uses associations and scopes. According to the > docs: > > All \scopes are available as class methods on the ActiveRecord::Base > descendent upon which the \scopes were defined. But they are also > available to has_many associations. If, > class Person < ActiveRecord::Base > has_many :shirts > end > then elton.shirts.red.dry_clean_only will return all of Elton's red, > dry clean only shirts. > > > So a better example would be: > b = Blog.first > b.entries.unseen > > I guess in this case, the method :unseen is bound to the set returned > via the association, and not the class itself? > > I'm not too sure what you mean by that. As I've used named scopes, I have been confused by thinking that entries.unseen was an array such as is returned by #find, when, it seems, it is a piece of RoR magic that looks more like the model. I wonder if b.entries.unseen.all or b.entries.unseen.first might do what you need it to. (Between you and me, I'm hoping that somebody who knows what (s)he is talking about chimes in here pretty soon, as this is already out of my depth. :-)) --wpd --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---