Skip to content

Commit

Permalink
Use Rails-provided module for migration numbering
Browse files Browse the repository at this point in the history
  • Loading branch information
norman committed Sep 9, 2011
1 parent 1a2bc54 commit c03879a
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions lib/generators/friendly_id_generator.rb
@@ -1,10 +1,11 @@
require 'rails/generators'
require 'rails/generators/migration'
require "rails/generators/active_record"

# This generator adds a migration for the {FriendlyId::History
# FriendlyId::History} addon.
class FriendlyIdGenerator < Rails::Generators::Base
include Rails::Generators::Migration
extend ActiveRecord::Generators::Migration

source_root File.expand_path('../../friendly_id', __FILE__)

Expand All @@ -13,14 +14,4 @@ def copy_files(*args)
migration_template 'migration.rb', 'db/migrate/create_friendly_id_slugs.rb'
end

# TODO: use the module provided with Rails, no need to do this
# any more
# Taken from ActiveRecord's migration generator
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
end

0 comments on commit c03879a

Please sign in to comment.