Skip to content

Commit

Permalink
add rails 3 generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Dariusz Gertych committed Jan 12, 2011
1 parent aea06b7 commit d86c0ab
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1 +1,2 @@
pkg
.DS_Store
2 changes: 2 additions & 0 deletions lib/generators/timeline_fu/USAGE
@@ -0,0 +1,2 @@
Generates both the TimelineEvent class and the migration to create its table. The table will have subject, actor and secondary actor as polymorphic associations.
The use of this generator is optional. See README for more details.
21 changes: 21 additions & 0 deletions lib/generators/timeline_fu/timeline_fu_generator.rb
@@ -0,0 +1,21 @@
require 'rails/generators'
require 'rails/generators/migration'

class TimelineFuGenerator < Rails::Generators::Base
include Rails::Generators::Migration
source_root File.expand_path(File.join('..', '..', '..', 'generators', 'timeline_fu', 'templates'), File.dirname(__FILE__))


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
copy_file 'model.rb', 'app/models/timeline_event.rb'
migration_template 'migration.rb', 'db/migrate/create_timeline_events.rb'
end
end

0 comments on commit d86c0ab

Please sign in to comment.