Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Modified generator to work with Rails 3

  • Loading branch information...
commit 66a7575293d101a93aa7f9ba54ab385a17fdff59 1 parent f38301d
@talakoski talakoski authored
View
14 generators/party_boy/party_boy_generator.rb
@@ -1,14 +0,0 @@
-class PartyBoyGenerator < Rails::Generator::Base
- def manifest
- record do |m|
- m.directory "app/models"
- m.template "model.rb", "app/models/relationship.rb"
-
- m.migration_template 'migration.rb', 'db/migrate'
- end
- end
-
- def file_name
- "party_boy_migration"
- end
-end
View
20 lib/generators/party_boy/party_boy_generator.rb
@@ -0,0 +1,20 @@
+require 'rails/generators/migration'
+
+class PartyBoyGenerator < Rails::Generators::Base
+ include Rails::Generators::Migration
+
+ source_root File.expand_path('../templates', __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_model_file
+ copy_file "model.rb", "app/models/relationship.rb"
+ migration_template "migration.rb", "db/migrate/create_relationship.rb"
+ end
+end
View
0  generators/party_boy/templates/migration.rb → lib/generators/party_boy/templates/migration.rb
File renamed without changes
View
0  generators/party_boy/templates/model.rb → lib/generators/party_boy/templates/model.rb
File renamed without changes
Please sign in to comment.
Something went wrong with that request. Please try again.