Permalink
Browse files

move files into rails 3 location

  • Loading branch information...
1 parent feb10bb commit 0a9b778fcc4040029e1e4a441e9b933cca811ca8 @jackdempsey committed May 17, 2011
@@ -1,7 +0,0 @@
-class PreferencesGenerator < Rails::Generator::Base
- def manifest
- record do |m|
- m.migration_template '001_create_preferences.rb', 'db/migrate', :migration_file_name => 'create_preferences'
- end
- end
-end
@@ -1,5 +1,5 @@
Usage:
- script/generate preferences
+ rails generate preferences
This will create a migration that will add the proper table to store preferences.
@@ -0,0 +1,17 @@
+class PreferencesGenerator < 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_migration_file
+ migration_template 'create_preferences.rb', "db/migrate/create_preferences.rb"
+ end
+end
@@ -1,5 +1,5 @@
class CreatePreferences < ActiveRecord::Migration
- def self.up
+ def change
create_table :preferences do |t|
t.string :name, :null => false
t.references :owner, :polymorphic => true, :null => false
@@ -9,8 +9,4 @@ def self.up
end
add_index :preferences, [:owner_id, :owner_type, :name, :group_id, :group_type], :unique => true, :name => 'index_preferences_on_owner_and_name_and_preference'
end
-
- def self.down
- drop_table :preferences
- end
end

0 comments on commit 0a9b778

Please sign in to comment.