I’ve got the following setup:
category (hm) <-> (bt) activity
An activity has an amount, date, location, note, and category. I’m
sorting my activities table by category_id (foreign key in activity),
but how do I sort it by category_name instead? Basically I just need
category_name in the result set. Here’s what I have now:
@all = Activity.find(:all, :order => ‘category’)
How do I grab the category_name column from Category so that it is part
of @all?
Thanks!
On Sun, Jan 08, 2006 at 10:02:36PM +0100, Chris S. wrote:
How do I grab the category_name column from Category so that it is part
of @all?
You can eagerly load the category then reference one of its columns in
the
:order.
Activity.find(:all, :include => :category, :order => ‘categories.name’)
marcel
Marcel Molina Jr. wrote:
On Sun, Jan 08, 2006 at 10:02:36PM +0100, Chris S. wrote:
How do I grab the category_name column from Category so that it is part
of @all?
You can eagerly load the category then reference one of its columns in
the
:order.
Activity.find(:all, :include => :category, :order => ‘categories.name’)
marcel
Awesome, thanks. I knew it was something straightforward.