Skip to content
Browse files

move files into rails 3 location

  • Loading branch information...
1 parent 2fc9127 commit 4cfd6637c628483eaa564eb74fa581b5d18299f2 @jackdempsey jackdempsey committed with rds May 17, 2011
View
7 generators/preferences/preferences_generator.rb
@@ -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
View
2 generators/preferences/USAGE → lib/generators/USAGE
@@ -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.
View
17 lib/generators/preferences_generator.rb
@@ -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
View
6 ...ences/templates/001_create_preferences.rb → ...enerators/templates/create_preferences.rb
@@ -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 4cfd663

Please sign in to comment.
Something went wrong with that request. Please try again.