class PaperclipDatabase::Generators::MigrationGenerator
Public Class Methods
source_root()
click to toggle source
# File lib/generators/paperclip_database/migration/migration_generator.rb, line 16 def self.source_root @source_root ||= File.expand_path('../templates', __FILE__) end
Public Instance Methods
generate_migration()
click to toggle source
# File lib/generators/paperclip_database/migration/migration_generator.rb, line 20 def generate_migration migration_template "migration.rb.erb", "db/migrate/#{migration_file_name}", migration_version: migration_version end
migration_class_name()
click to toggle source
# File lib/generators/paperclip_database/migration/migration_generator.rb, line 32 def migration_class_name migration_name.camelize end
migration_file_name()
click to toggle source
# File lib/generators/paperclip_database/migration/migration_generator.rb, line 28 def migration_file_name "#{migration_name}.rb" end
migration_name()
click to toggle source
# File lib/generators/paperclip_database/migration/migration_generator.rb, line 24 def migration_name "create_#{name.underscore.tr('/', '_')}_#{attachment_names.map{|n| n.pluralize}.join('_and_')}" end
migration_version()
click to toggle source
# File lib/generators/paperclip_database/migration/migration_generator.rb, line 36 def migration_version if Rails.version.to_i >= 5 "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" end end