Fix ActiveRecord errors in Rails 4+ within generators