Group.find(:all, :include=>:categories,
:order=>''groups.sortorder,
categories.sortorder'')
On Mar 12, 5:04 pm, Michael Satterwhite <rails-mailing-l...@andreas-
s.net> wrote:> I have two related tables: groups and categories. In the models,
>
> Group
> has_many "categories"
>
> Category
> belongs_to :group
>
> Category does have a column, "group_id" as required.
> Both the groups and categories tables have a "sortorder" column
which
> dictates the order the items are to be presented.
>
> In my controller, I want to retrieve the Categories along with the
> information on the Group it belongs to. They should be retrieved in
> sortorder sequence with group having the highest precedence.
>
> How can I specify a find statement with an :order_by that specifies both
> Group.sortorder and Category.sortorder?
> --
> 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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---