Fix activerecord integration to work in rails >= 4.06

The method names have changed in activerecord.
Also see https://github.com/rails/rails/pull/11650