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.

I think the secret lies in distinct / uniq / find_by_sql somehow but try
as I might I just can't find the secret sauce. For a bonus burrito I'd
like the results ordered by given name.

Be very grateful for a solution.

-- 
Posted via http://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.

Reply via email to