Class: ActiveRecord::Generators::RolesMigrationGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Includes:
RailsAssist::Migration
Defined in:
lib/generators/active_record/roles_migration/roles_migration_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



21
22
23
24
25
# File 'lib/generators/active_record/roles_migration/roles_migration_generator.rb', line 21

def self.source_root 
  # use new reversible migrations with #change method for Rails 3.1
  postfix = Rails::VERSION.include?('3.1') ? "/3_1" : ""
  @source_root ||= File.expand_path("../templates#{postfix}", __FILE__)
end

Instance Method Details

#mainObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/generators/active_record/roles_migration/roles_migration_generator.rb', line 27

def main
  if logging?
    require 'logging_assist'
    self.class.send :include, Rails3::Assist::BasicLogger
    logger.add_logfile :logfile => logfile if logfile
  end

  valid_strategy?
  run_migration
end