Consider this situation
class Property < ActiveRecord::Base
Now if you reference:
It reloads the property. I’m looking for a way to suggest the
association directly to the associated objects.
I know this example seems contrived, but it’s just a simplification.
In actuality my Photo model has a method that looks like this:
class Photo < ActiveRecord::Base
File.join(“images”, property.idx.name, filename)
Not only does this result in n+1 queries, but it actually results in 2n
+1, even though I am eager loading all the necessary data up front.
I can think of a lot of ways to solve this, but to cleanly solve it
requires somehow suggesting the existing loaded @property object to
the photo.property assocation. If there’s no way to do this, maybe
there should be…