On 10 August 2010 13:44, Mike Disuza <[email protected]> wrote: > > > Hi, > I have a Person model and Company model like as follows:- > > Person.rb > > class Person <ActiveRecord::Base > has_one :company > end > > Company.rb > class Company < ActiveRecord::Base > end > > I have a function > def person_details > �...@person=person.find(params[:id, :include=> :company) > end > > person_details.html.erb > <%[email protected]%> : <%[email protected]%> > > I read that if you use the :include option then it reduces your number > of queries. > Means, whenever it is firing a query to find person same time it eager > loads the company association. > > I am confused that what exactly it does? Is it load the company object > in memory? and instead of going to database it takes it from memory.
Write some code that uses your find and then accesses person.company and look in the log to see the queries being used. Repeat without the :include and you will see the difference. Colin -- 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.

