Skip to content

Commit

Permalink
Rails 3 migration file generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandip Ransing committed Feb 11, 2011
1 parent ed0ed24 commit 51c2832
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -18,7 +18,7 @@ Features
---------------------
rails plugin install git://github.com/sandipransing/rails_tiny_mce.git

rails g rails_tiny_mce_migration
rails g tiny_migration

rake db:migrate

Expand Down

This file was deleted.

20 changes: 20 additions & 0 deletions lib/generators/tiny_migration/tiny_migration_generator.rb
@@ -0,0 +1,20 @@
class TinyMigrationGenerator < Rails::Generator::Base
require 'rails/generators'
require 'rails/generators/migration'

include Rails::Generators::Migration
source_root File.expand_path('../templates', __FILE__)
# Implement the required interface for Rails::Generators::Migration.
# taken from http://github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb
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

def create_migration_file
migration_template 'migration.rb', 'db/migrate/create_tiny_media.rb'
end
end

0 comments on commit 51c2832

Please sign in to comment.