I know this is probably a noob question, but I needed a little
clarification. I did the following in the console of my app:

>> User.find(:all, :conditions => "orders.id > 1", :joins => :orders).size
=> 1254

>> User.find(:all, :conditions => "orders.id > 1", :include => :orders).size
=> 934

A user has many orders. Why am I getting different results? When using
fields in a has_many relationship should I ALWAYS use the :include
option. I did the reverse too:

>> Order.find(:all, :conditions => "users.id < 100", :joins => :user).size
=> 172

>> Order.find(:all, :conditions => "users.id < 100", :include => :user).size
=> 172

I'm getting the same result. What is the general rule of thumb on when
to use joins or includes?

Thanks for your help!
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
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