Permalink
Browse files

add rails 3 generator

  • Loading branch information...
1 parent aea06b7 commit 476d60d95fd96d3a9847acac43786ada74d2c510 Dariusz Gertych committed with Jan 12, 2011
Showing with 24 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +2 −0 lib/generators/timeline_fu/USAGE
  3. +21 −0 lib/generators/timeline_fu/timeline_fu_generator.rb
View
@@ -1 +1,2 @@
pkg
+.DS_Store
@@ -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.
@@ -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 476d60d

Please sign in to comment.