1

Manufacturer

has_many :product 

Product

has_many :part 

PartsRequest

belongs_to :part belongs_to :manufacturer 

I am trying to do something in PartsRequest e.g. Manufacturer A is trying to request for Parts from Manufacturer B

scope :incoming_requests, lambda { |manufacturer_id| joins(:part).joins(product).where("product.manufacturer_id = ?", manufacturer_id) } 

How do I join to parts, then from parts join with products?

1
  • 2
    Are you just looking for joins(:part => :product) or is it more complex than that? Commented Nov 10, 2011 at 6:54

1 Answer 1

4
scope :incoming_requests, lambda{|mid| joins(:part => :product).where(:product => {:manufacturer_id => mid}) } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.