Use of :include option in find query

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.

Can anyone elaborate me what exactly happens when we use the :include
option.

Thanks,
Mike

Sorry for posting the question in Rails deployment section. I have added
in Ruby On Rails section.
Mike D. wrote:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs