6

I tried placing my custom file in multiple locations inside the lib folder with no success.

I found a PR from 2017 to reactivate this behavior but wasn't merged. https://github.com/rails/rails/pull/13972

I had a look at https://github.com/rails/rails/blob/master/activerecord/lib/rails/generators/active_record/migration/migration_generator.rb#L17

and it looks like it's not implemented, but I don't know if just this file should change.

I´ve found resources on how to do it in older rails versions, but is there any way to override the Rails templates in Rails 6?

Iván Quiñones
  • 501
  • 4
  • 12

1 Answers1

-1

From this line of the documentation:

Since we want to customize Rails::Generators::HelperGenerator, we can do that by simply making a template copy inside lib/templates/rails/helper with the name helper.rb.

In the case for migrations, the template names should be specified as follows (here are the default templates for reference):

  • lib/templates/active_record/migration/create_table_migration.rb.tt
  • lib/templates/active_record/migration/migration.rb.tt
nfisher
  • 57
  • 1
  • 10