rails/rails — pull request #16448 by skanev (2014-08-09 21:00:20+00:00)
Title: Fix `touch: true` in polymorphic relations

Fixes #16446.

`touch: true` relies on the inverse of a relationship. It couldn't be found automatically for a `has_many :as`. Removing a (seemingly) unnecessary check took care of that.

There was a test explicitly checking that the inverse of `has_many :foo, as: :bar` cannot be automatically discovered. The test was introduced in #15343, fixing #15337. I executed [the gist with the reproduction][the-gist] after my change and it runs without errors. I couldn't see the relation between the test and issue, so I changed the test.

Removing the call to `can_find_inverse_of_automatically?` can have some side-effects that I haven't considered. From what I can tell, it's pretty safe, but I might be missing something.

/cc @senny

[the-gist]: https://gist.github.com/dontfidget/c5cf589d4fb8994afd8b