Is there a way for me to do:
OrderItem.find(:all, :include => [:user, :product => [:supplier]]
So I don’t have a supplier_id on my order_item, but have it on my
product, which is part of order_item.
Joerg
Is there a way for me to do:
OrderItem.find(:all, :include => [:user, :product => [:supplier]]
So I don’t have a supplier_id on my order_item, but have it on my
product, which is part of order_item.
Joerg
I think this is only possible in edgerails. Alternatively, you can use
find_by_sql
Joerg D. wrote:
Is there a way for me to do:
OrderItem.find(:all, :include => [:user, :product => [:supplier]]
So I don’t have a supplier_id on my order_item, but have it on my
product, which is part of order_item.Joerg
Running EdgeRails. Would you know what the syntax is?
Cheltis wrote:
I think this is only possible in edgerails. Alternatively, you can use
find_by_sql
Joerg D. wrote:Is there a way for me to do:
OrderItem.find(:all, :include => [:user, :product => [:supplier]]
So I don’t have a supplier_id on my order_item, but have it on my
product, which is part of order_item.Joerg
Edge rails supports cascading eager loading. You would do:
OrderItem.find(:all, :include => [:user, { :product => :supplier } ]
-Jonathan.
Joerg
> Is there a way for me to ..
I’m not sure I understand your example, but if you’re looking for nested
finds, the new way is to use
with_scope
Alain
The syntax for cascading eager loading does not work for me:
It ends up looking for an association called :productsupplier. I’ve
tried it using quotes instead, and I get the same problem.
Have you got this working? I am using an EdgeRails version a few days
old -> the current one throws an error starting WEBrick.
Joerg D. wrote:
Ah, ‘cascading eager loading’ … that’s what I was looking for!
Cool - thanks.Jonathan V. wrote:
Edge rails supports cascading eager loading. You would do:
OrderItem.find(:all, :include => [:user, { :product => :supplier } ]
-Jonathan.
It was added in r3769, so anything after that should work.
It works fine for me. Double check you’ve got the correct names for the
associations you are including.
-Jonathan.
Ah, ‘cascading eager loading’ … that’s what I was looking for!
Cool - thanks.
Jonathan V. wrote:
Edge rails supports cascading eager loading. You would do:
OrderItem.find(:all, :include => [:user, { :product => :supplier } ]
-Jonathan.
It’s working thanks - got the latest version and commented out some
lines in the server.rb file to make WEBrick start up again.
Jonathan V. wrote:
It was added in r3769, so anything after that should work.
It works fine for me. Double check you’ve got the correct names for the
associations you are including.-Jonathan.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs