has_many :through efficiency issue on <<

In has_many_through_association.rb:

      def <<(*records)         ...         load_target

        ...

            @target << associate           end         end       end

In the interests of making the lazy loading lazier, wouldn't it be better to *not* load the target, and instead:

            @target << associate if loaded?

When you have a lot of target records the load can be a significant hit. Am I misunderstanding this? Is there any reason not to prefer it this way?

Evan Weaver

+1

Now with a patch and tests: http://dev.rubyonrails.org/ticket/8150

Evan

Applied, cheers!