In rails, you can get loading associations when creating a new object as follows:
@person = Person.find(params[:id], :include => {:flights => :plane})
However, I sometimes already have an @person object, and then I want it to load associations. It seems that there is no way to "rails". I am looking for something like this basically:
@person = Person.find(params[:id]) ... @person.include({:flights => :plane})
There is a background, I have a before filter, which already creates an @object without associations. But in some actions, if I do not want to load associations, I will create many singular queries. And making
@person = Person.find(params[:id]) ... @person = Person.find(params[:id], :include => {:flights => :plane})
seems a bit unnecessary.
source share