class PaperTrail::MigrationGenerator
Basic structure to support a generator that builds a migration
Public Class Methods
next_migration_number(dirname)
click to toggle source
# File lib/generators/paper_trail/migration_generator.rb, line 11 def self.next_migration_number(dirname) ::ActiveRecord::Generators::Base.next_migration_number(dirname) end
Protected Instance Methods
add_paper_trail_migration(template, extra_options = {})
click to toggle source
# File lib/generators/paper_trail/migration_generator.rb, line 17 def add_paper_trail_migration(template, extra_options = {}) migration_dir = File.expand_path("db/migrate") if self.class.migration_exists?(migration_dir, template) ::Kernel.warn "Migration already exists: #{template}" else migration_template( "#{template}.rb.erb", "db/migrate/#{template}.rb", { migration_version: migration_version }.merge(extra_options) ) end end
migration_version()
click to toggle source
# File lib/generators/paper_trail/migration_generator.rb, line 30 def migration_version format( "[%d.%d]", ActiveRecord::VERSION::MAJOR, ActiveRecord::VERSION::MINOR ) end