Camparing table and instance of another table

Hi, I did the following to compare two tables, products and orders using
LEFT OUTER JOIN. It came out fine.

However, I am not sure how to do the similar join if the products are an
array. For example, there is another table called brands having the
relationships - brand has_many:products and products belongs_to:brand.
@brands = brand.find(params[:id])picks up particular brand and all the
products from that brand.

On the view, I would like to display list of products from one brand and
do LEFT OUTER JOIN with orders table. I would truly appreciate the
advise on how to modify the following to accomplish this task or at
least guide me to the right direction.

Table products

Table orders

product has_many: orders
order belongs_to: product

Def list
@products = Product.find(:all)
@orders = Order.find(:all)
@compares = Product.connection.select_all(“SELECT AS
prod, AS name, orders.product_id AS ord FROM
products LEFT OUTER JOIN orders ON = orders.product_id”)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs