lib/generators/paperclip/paperclip_generator.rb in paperclip-5.2.1 vs lib/generators/paperclip/paperclip_generator.rb in paperclip-5.3.0

- old
+ new

@@ -11,11 +11,13 @@ def self.source_root @source_root ||= File.expand_path('../templates', __FILE__) 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 "add_attachment_#{attachment_names.join("_")}_to_#{name.underscore.pluralize}" end @@ -24,7 +26,13 @@ "#{migration_name}.rb" end 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