Class: FriendlyIdGenerator

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

Constant Summary collapse

MIGRATIONS_FILE =
File.join(File.dirname(__FILE__), "..", "..", "generators", "friendly_id", "templates", "create_slugs.rb")

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object

Taken from ActiveRecord’s migration generator



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

def self.next_migration_number(dirname) #:nodoc:
  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_files(*args) ⇒ Object



12
13
14
# File 'lib/generators/friendly_id_generator.rb', line 12

def copy_files(*args)
  migration_template MIGRATIONS_FILE, "db/migrate/create_slugs.rb" unless options["skip-migration"]
end