Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add rails 3 generator

  • Loading branch information...
commit 476d60d95fd96d3a9847acac43786ada74d2c510 1 parent aea06b7
Dariusz Gertych authored committed
1  .gitignore
View
@@ -1 +1,2 @@
pkg
+.DS_Store
2  lib/generators/timeline_fu/USAGE
View
@@ -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 lib/generators/timeline_fu/timeline_fu_generator.rb
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.