rails/rails — pull request #9371 by benmoss (2013-02-22 04:46:56+00:00)
Title: Access an instance's connection via its class, rather than via #connection

Had a problem today where we had a `belongs_to :connection` on our model. Hadn't occurred to me that this might be a problem, but when we ran our tests we were getting an obscure `undefined method substitute_at for nil:NilClass` exception.

Discovered the root cause was this method, which was attempting to call `connection` on the AR instance, which just delegates to the class anyway. I can't think of how this could add any problems that aren't already in the current implementation. I wasn't sure if I should provide a regression test for this, but would be happy to if it's required.