This is a beginner's question but for some reason I cannot find the answer elsewhere.
Customer has_many orders
Order has_many order_items
I am in customer/show.html.erb and I want my customer to manipulate order_items.
Many orders have many order_items and I want to search ALL of those order_items to find those such that read == false.
#controller
@customer = Customer.find(params[:id])
@orders = @customer.orders
@order_items = @orders.order_items doesn't work. Given that I have multiple items in @orders, how can I collect all the order_items that belong to @orders?
=== EDIT ===
My entire database structure is a big complicated group of tables and I need to traverse that tree for this particular view.
customer has_many orders
orders has_many order_items
order_items belongs_to category
How do I, for example, find the number of my customer's order_items that belong to category X?
Last question: why doesn't @orders.find_all_by_x(...) work?