Class: SettingsGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/settings/settings_generator.rb

Constant Summary

@@migrations =
false

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) next_migration_number(dirname)

:nodoc:



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/generators/settings/settings_generator.rb', line 12

def self.next_migration_number(dirname) #:nodoc:
  if ActiveRecord::Base.timestamped_migrations
    if @@migrations          
      (current_migration_number(dirname) + 1)
    else
      @@migrations = true
      Time.now.utc.strftime("%Y%m%d%H%M%S")
    end
  else
    "%.3d" % (current_migration_number(dirname) + 1)
  end
end

Instance Method Details

- (Object) settings



25
26
27
28
29
# File 'lib/generators/settings/settings_generator.rb', line 25

def settings      
  #generate(:model, name, "--skip-migration")
  template "model.rb", File.join("app/models",class_path,"#{file_name}.rb"), :force => true
  migration_template "migration.rb", "db/migrate/create_settings.rb"
end