I execute a query with several :includes in it.
For example, let’s say I use
test = ModelClassName.find( id, :include => [ :table_1, :table_2 ])
Now test has methods called has_table_1? and has_table_2?
If joined table_1 is not nil for this result (i.e. test.has_table_1? ==
I can simply get all attributes of table_1 using
and this wouldn’t cause additional databse query;
But if test.has_table_1? == false, or, the same, test.table_1 == nil;
calling of this methods (has_table_1? or test.table_1 == nil) creates
additional query: SELECT * FROM table_1 WHERE (table_1.id = …)
So the question is: how to change this behaviour to avoid additional