Nevermind, I figured it out.
self.find_all_by_client_id(client_id, :include => {:item
=> :item_type}, :order => "item_types.name, items.name")
On Oct 22, 5:17 pm, "randomutterings..."
<randomutteri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I''m using find_by_sql in my barcode model and I want to use the
> will_paginate plugin with it. will_paginate works like a find
> replacement so I need to modify this code to use a regular find method
> instead of find_by_sql.
>
> def self.all(client_id)
> self.find_by_sql("select * from barcodes inner join items on
> barcodes.item_id = items.id inner join item_types on
> items.item_type_id = item_types.id where barcodes.client_id = " +
> client_id.to_s + " order by item_types.name, items.name")
> end
>
> Barcode belongs to Item
> Item belongs to ItemType
>
> The reason for this find_by_sql is that I want the barcodes sorted
> first by item_type.name then by item.name.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---