James Byrne wrote in post #975768:
> Colin Law wrote in post #975760:
>
>> I am interested to know why, when you do not care what the rest of the
>> row contains.
>>
>
> I have answered that question. I just want to quickly obtain one
> representative row from each category.  I can get the same result by
> iterating over an array of possible values and doing a
> find_by_category(x).first on each.  I would prefer a less cumbersome
> approach.
>
> Do you know how to accomplish what I desire?  If so then I would
> appreciate it if you would tell me.

This is actually a common issue with Object-Relational-Mapping (ORM), 
such as ActiveRecord. Each instance of an ActiveRecord subclass 
represent a specific row in a database table. Objects have identity, and 
in an ORM system identity is maintained by mapping the database row's 
primary key to a specific ActiveRecord subclass instance.

What you have presented here is a SQL problem that doesn't not map 
easily into an ORM system. This is what others have been attempting 
implying. What you have presented here is a SQL problem I'd suggest 
using SQL to solve it. You should be able to run any arbitrary SQL you 
want. All you need is the database connection and execute your SQL.

I'm not going to go out of my way to try to figure out the required SQL 
to accomplish your goal. I don't know of a way to solve your problem 
through any ORM. You need to drop down to the SQL level to solve it if 
it's really something your design requires.

This requirement in itself raises questions about your design in my 
mind, but it's your project and you're closer to the problem domain.

-- 
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 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.

Reply via email to