Class: Lockbox::Generators::AuditsGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Lockbox::Generators::AuditsGenerator
- Includes:
- ActiveRecord::Generators::Migration
- Defined in:
- lib/generators/lockbox/audits_generator.rb
Instance Method Summary collapse
Instance Method Details
#copy_migration ⇒ Object
9 10 11 12 |
# File 'lib/generators/lockbox/audits_generator.rb', line 9 def copy_migration migration_template "migration.rb", "db/migrate/create_lockbox_audits.rb", migration_version: migration_version template "model.rb", "app/models/lockbox_audit.rb" end |
#data_type ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/generators/lockbox/audits_generator.rb', line 18 def data_type # use connection_config instead of connection.adapter # so database connection isn't needed case ActiveRecord::Base.connection_config[:adapter].to_s when /postg/i # postgres, postgis "jsonb" when /mysql/i "json" else "text" end end |
#migration_version ⇒ Object
14 15 16 |
# File 'lib/generators/lockbox/audits_generator.rb', line 14 def migration_version "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]" end |