class OrderItem belongs_to Item and belongs_to Order class Item has_many OrderItems and belongs_to ItemType class ItemType has_many Items class Order has_many OrderItems
I would like to find all OrderItems within the order whose elements are of the type ItemType
def get_by_item_type(id) order_items.where(:item => {:item_type_id => 3})
Obviously, I can do this by finding all OrderItems, looping, testing, and creating my own collection. No problem, but I wonder if there is another way?
Thanks / J
source share