On 16 March 2012 15:41, bingo bob <[email protected]> wrote: > I'm going around in circles with this one can't solve it. > > I have a database with a lot of Name objects in it, some have the same > given name - ok fairly normal. > > Name > given (string) > gender (string) # it's either m or f, not really relevant > position (integer) # not really relevant > user_id (integer) # it's either m or f, not really relevant > > I simply wish to return all the Names with a unique given name. > *important* I an array of objects returned not just the given names so I > can access all the attributes of the name when they're returned, i.e. in > my view I need the full object to get at the user and gender etc.
If I understand correctly, then in the case where there are several records with given == "fred" for example, then you want to get a Name object back so you can access the other attributes. But how will the code know which of the records with given == "fred" that you want? The other attributes may be different between the fred records. Colin -- 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.

