Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use Rails 3.1 `change` method in model generator

  • Loading branch information...
commit 9e64dfad0df4ed8a10d2ad2a17cd0848017d652c 1 parent 40afcad
@sikachu sikachu authored tenderlove committed
View
6 activerecord/lib/rails/generators/active_record/model/templates/migration.rb
@@ -1,5 +1,5 @@
class <%= migration_class_name %> < ActiveRecord::Migration
- def up
+ def change
create_table :<%= table_name %> do |t|
<% for attribute in attributes -%>
t.<%= attribute.type %> :<%= attribute.name %>
@@ -13,8 +13,4 @@ def up
add_index :<%= table_name %>, :<%= attribute.name %>_id
<% end -%>
end
-
- def down
- drop_table :<%= table_name %>
- end
end
View
8 railties/test/generators/model_generator_test.rb
@@ -99,15 +99,11 @@ def test_migration_with_attributes
run_generator ["product", "name:string", "supplier_id:integer"]
assert_migration "db/migrate/create_products.rb" do |m|
- assert_method :up, m do |up|
+ assert_method :change, m do |up|
assert_match /create_table :products/, up
assert_match /t\.string :name/, up
assert_match /t\.integer :supplier_id/, up
end
-
- assert_method :down, m do |down|
- assert_match /drop_table :products/, down
- end
end
end
@@ -141,7 +137,7 @@ def test_migration_timestamps_are_skipped
run_generator ["account", "--no-timestamps"]
assert_migration "db/migrate/create_accounts.rb" do |m|
- assert_method :up, m do |up|
+ assert_method :change, m do |up|
assert_no_match /t.timestamps/, up
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.