OK I'm dumb; you definitely don't need a virtual attribute for that (not really sure what i was thinking), but its still ugly probably not worth doing.
On May 12, 4:49 pm, pharrington <[email protected]> wrote: > Yeah I deleted that post immediately after because that selects > child.name. Something like :select => "mothers.name AS mother_name" > would probably work, but just ugly AND then you'd need a mother_name > virtual attribute in the Child model, making things rather needlessly > horrific. I really can't think of a good way (without raw SQL) to do > this in one query either. > > On May 12, 3:33 pm, Colin Law <[email protected]> wrote: > > > 2009/5/12 pharrington <[email protected]> > > > > If you want to retrieve just the name, than use the :select option > > > with your find: > > > > @children = Child.find(:all, :include => :mother, :select => 'name') > > > Does that select child.name or mother.name? > > Colin > > > > On May 12, 11:04 am, Colin Law <[email protected]> wrote: > > > > 2009/5/12 Anthony Ward <[email protected]> > > > > > > Hi thank you > > > > > > so if I use the include > > > > > how do i just retrieve the name then > > > > > Do you mean you want a query finding the child, including the > > > > mother.namebut not the other mother fields? I do not know whether you > > > > can do that. I > > > > think the overhead of fetching all columns is going to be rather small. > > > > Colin > > > > > > example this is using the "magic way" > > > > > > @children do |child| > > > > > > ... print child.mother.name > > > > > > end > > > > > > -- > > > > > Posted viahttp://www.ruby-forum.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 -~----------~----~----~----~------~----~------~--~---

