Skip to content

Commit

Permalink
Change migration.rb to erb
Browse files Browse the repository at this point in the history
Avoids rubocop complaining and is more accurate now that it isn't used
as plain old ruby file.
  • Loading branch information
jnunemaker committed Nov 4, 2017
1 parent 05bcb2a commit e327b8d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion flipper-active_record.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 9 additions & 4 deletions lib/generators/flipper/active_record_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e327b8d

Please sign in to comment.