Class: ActiveRecord::Generators::HasMediaGenerator

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

Overview

Cannot inhérit from ActiveRecord::Generators::Base see groups.google.com/group/rubyonrails-talk/browse_thread/thread/a507ce419076cda2

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object

Implement the required interface for Rails::Generators::Migration. taken from github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb



17
18
19
20
21
22
23
# File 'lib/generators/active_record/has_media_generator.rb', line 17

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

Instance Method Details

#copy_has_media_migrationObject



11
12
13
# File 'lib/generators/active_record/has_media_generator.rb', line 11

def copy_has_media_migration
  migration_template "migration.rb", "db/migrate/create_has_media"
end