diff --git a/flipper-active_record.gemspec b/flipper-active_record.gemspec index 30aaed4b2..ad2f28837 100644 --- a/flipper-active_record.gemspec +++ b/flipper-active_record.gemspec @@ -14,7 +14,7 @@ Gem::Specification.new do |gem| gem.homepage = 'https://github.com/jnunemaker/flipper' extra_files = [ - 'lib/generators/flipper/templates/migration.rb', + 'lib/generators/flipper/templates/migration.erb', 'lib/flipper/version.rb', ] gem.files = `git ls-files`.split("\n").select(&flipper_active_record_files) + extra_files diff --git a/lib/generators/flipper/active_record_generator.rb b/lib/generators/flipper/active_record_generator.rb index 13a00c2f6..212a5e2a9 100644 --- a/lib/generators/flipper/active_record_generator.rb +++ b/lib/generators/flipper/active_record_generator.rb @@ -13,13 +13,18 @@ def self.next_migration_number(dirname) end def self.migration_version - if Rails.version.start_with?('5') - "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" - end + "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" if rails5? + end + + def self.rails5? + Rails.version.start_with?('5') end def create_migration_file - migration_template 'migration.rb', 'db/migrate/create_flipper_tables.rb', migration_version: migration_version + options = { + migration_version: migration_version, + } + migration_template 'migration.erb', 'db/migrate/create_flipper_tables.rb', options end def migration_version diff --git a/lib/generators/flipper/templates/migration.rb b/lib/generators/flipper/templates/migration.erb similarity index 100% rename from lib/generators/flipper/templates/migration.rb rename to lib/generators/flipper/templates/migration.erb