Class: PaperTrailAssociationTracking::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/paper_trail_association_tracking/install_generator.rb

Overview

Installs PaperTrail in a rails app.

Constant Summary collapse

MYSQL_ADAPTERS =

Class names of MySQL adapters.

  • `MysqlAdapter` - Used by gems: `mysql`, `activerecord-jdbcmysql-adapter`.

  • `Mysql2Adapter` - Used by `mysql2` gem.

[
  "ActiveRecord::ConnectionAdapters::MysqlAdapter",
  "ActiveRecord::ConnectionAdapters::Mysql2Adapter"
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object


36
37
38
# File 'lib/generators/paper_trail_association_tracking/install_generator.rb', line 36

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

Instance Method Details

#create_initializerObject


28
29
30
31
32
33
34
# File 'lib/generators/paper_trail_association_tracking/install_generator.rb', line 28

def create_initializer
  create_file(
    "config/initializers/paper_trail.rb",
    "PaperTrail.config.track_associations = true\n",
    "PaperTrail.config.association_reify_error_behaviour = :error"
  )
end

#create_migrationsObject


23
24
25
26
# File 'lib/generators/paper_trail_association_tracking/install_generator.rb', line 23

def create_migrations
  add_paper_trail_migration("create_version_associations")
  add_paper_trail_migration("add_transaction_id_column_to_versions")
end