Refactoring Help

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.

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…” [email protected]