Class: PhocoderRails::Generators::ModelUpdateGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/generators/phocoder_rails/model_update_generator.rb', line 15

def self.next_migration_number(dirname)
  if ActiveRecord::Base.timestamped_migrations
    Time.new.utc.strftime("%Y%m%d%H%M%S")
  else
    "%.3d" % (current_migration_number(dirname) + 1)
  end
end

Instance Method Details

#create_migration_fileObject



23
24
25
26
# File 'lib/generators/phocoder_rails/model_update_generator.rb', line 23

def create_migration_file
  migration_template 'model_update_migration.rb', "db/migrate/make_#{file_name.pluralize}_encodable.rb"
  #migration_template 'model_thumbnail_migration.rb', "db/migrate/create_#{file_name.singularize}_thumbnails.rb"
end

#create_model_fileObject



28
29
30
31
# File 'lib/generators/phocoder_rails/model_update_generator.rb', line 28

def create_model_file
  #template 'model.rb', File.join('app/models', class_path, "#{file_name.singularize}.rb")
  template 'model_thumbnail.rb', File.join('app/models', class_path, "#{file_name.singularize}_thumbnail.rb")
end