Add AR version-dependant code (Rails 3 and 4)