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`. This change allows for the inverse of `has_many` side of a polymorphic relation to be discovered automatically (but not the other way around).

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.

/cc @senny

[the-gist]: https://gist.github.com/dontfidget/c5cf589d4fb8994afd8b
I know there's been a big push to avoid using `:macro` for checks like this.