I have this simple model with orders and products. Orders looks like
this:

class Order < ActiveRecord::Base
  has_many :orders_products, :foreign_key => :order_id
  has_many :products, :through => :orders_products
  has_many :priority_products, :through => :orders_products, :source
=> :product, :conditions => { "orders_products.priority" => true }
end

The :condition on :priority_products is cause problems for me. It
worked fine in Rails 2.0.2, but breaks in Rails 2.1.1 when putting the
relation in a :include clause:

orders = Order.find(:all, :include => :priority_products)

This result in PostgreSQL saying: missing FROM-clause entry for table
"orders_products"

for this malformed query:

SELECT * FROM "products" WHERE ("products"."id" IN (1,2,3) AND
("orders_products"."priority" = 't'))

Full working example: http://pastie.org/299592

Is this something that should work, or am I making some mistake?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to