Commit c0cf4b61 by Jack Ellenberger Committed by Sid Raval

Add migration_version variable to migration generator for rails 5 compatibility (#2470)

* Add migration_version variable to migration generator for rails 5 compatibility

* Update syntax to satisfy hound
parent 76575c94
......@@ -13,7 +13,9 @@ class PaperclipGenerator < ActiveRecord::Generators::Base
end
def generate_migration
migration_template "paperclip_migration.rb.erb", "db/migrate/#{migration_file_name}"
migration_template("paperclip_migration.rb.erb",
"db/migrate/#{migration_file_name}",
migration_version: migration_version)
end
def migration_name
......@@ -27,4 +29,10 @@ class PaperclipGenerator < ActiveRecord::Generators::Base
def migration_class_name
migration_name.camelize
end
def migration_version
if Rails.version.start_with? "5"
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
end
end
end
class <%= migration_class_name %> < ActiveRecord::Migration
class <%= migration_class_name %> < ActiveRecord::Migration<%= migration_version %>
def self.up
change_table :<%= table_name %> do |t|
<% attachment_names.each do |attachment| -%>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment