Fix merge error when Equality LHS is non-attribute.

This is reworking of rails/rails/pull/7380 made for rails 3.
Merge pull request #11563 from 90yukke/fix-nomethoderror-on-non-attribute-equalities

Fix merge error when Equality LHS is non-attribute.