Sha256: ccf4a9b69418a486306591567558d763f179673a514cc17f327dc42faf4b9603

Contents?: true

Size: 879 Bytes

Versions: 3

Compression:

Stored size: 879 Bytes

Contents

require 'rails/generators'
require 'rails/generators/migration'
require 'rails/generators/active_record'

module PaperTrail
  class InstallGenerator < ::Rails::Generators::Base
    include ::Rails::Generators::Migration

    source_root File.expand_path('../templates', __FILE__)
    class_option :with_changes, :type => :boolean, :default => false, :desc => "Store changeset (diff) with each version"

    desc 'Generates (but does not run) a migration to add a versions table.'

    def create_migration_file
      migration_template 'create_versions.rb', 'db/migrate/create_versions.rb'
      migration_template 'add_object_changes_column_to_versions.rb', 'db/migrate/add_object_changes_column_to_versions.rb' if options.with_changes?
    end

    def self.next_migration_number(dirname)
      ::ActiveRecord::Generators::Base.next_migration_number(dirname)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
paper_trail-3.0.0 lib/generators/paper_trail/install_generator.rb
paper_trail-3.0.0.rc2 lib/generators/paper_trail/install_generator.rb
paper_trail-3.0.0.rc1 lib/generators/paper_trail/install_generator.rb