diff options
author | Dan Pickett <dpickett@enlightsolutions.com> | 2011-04-29 19:18:10 -0400 |
---|---|---|
committer | Dan Pickett <dpickett@enlightsolutions.com> | 2011-04-29 19:18:10 -0400 |
commit | 1efaed5af13f876833b3acd614e8d0116812f308 (patch) | |
tree | 8b2dd01afee8b4bdcf976d6a082d9fb89b32d43e /railties/guides/source/association_basics.textile | |
parent | 85c8d73642f03410b86ee842edcfe0eba1d4252c (diff) | |
parent | 010dbf7a2fd30f8dabebb3f04fed22c661d6bf80 (diff) | |
download | rails-1efaed5af13f876833b3acd614e8d0116812f308.tar.gz rails-1efaed5af13f876833b3acd614e8d0116812f308.tar.bz2 rails-1efaed5af13f876833b3acd614e8d0116812f308.zip |
Merge branch 'master' of github.com:lifo/docrails
Diffstat (limited to 'railties/guides/source/association_basics.textile')
-rw-r--r-- | railties/guides/source/association_basics.textile | 31 |
1 files changed, 5 insertions, 26 deletions
diff --git a/railties/guides/source/association_basics.textile b/railties/guides/source/association_basics.textile index e5b8c73c43..94dce1b97b 100644 --- a/railties/guides/source/association_basics.textile +++ b/railties/guides/source/association_basics.textile @@ -229,7 +229,7 @@ The corresponding migration might look like this: <ruby> class CreateSuppliers < ActiveRecord::Migration - def self.up + def change create_table :suppliers do |t| t.string :name t.timestamps @@ -241,11 +241,6 @@ class CreateSuppliers < ActiveRecord::Migration t.timestamps end end - - def self.down - drop_table :accounts - drop_table :suppliers - end end </ruby> @@ -314,7 +309,7 @@ If you have an instance of the +Picture+ model, you can get to its parent via +@ <ruby> class CreatePictures < ActiveRecord::Migration - def self.up + def change create_table :pictures do |t| t.string :name t.integer :imageable_id @@ -322,10 +317,6 @@ class CreatePictures < ActiveRecord::Migration t.timestamps end end - - def self.down - drop_table :pictures - end end </ruby> @@ -333,17 +324,13 @@ This migration can be simplified by using the +t.references+ form: <ruby> class CreatePictures < ActiveRecord::Migration - def self.up + def change create_table :pictures do |t| t.string :name t.references :imageable, :polymorphic => true t.timestamps end end - - def self.down - drop_table :pictures - end end </ruby> @@ -413,17 +400,13 @@ This declaration needs to be backed up by the proper foreign key declaration on <ruby> class CreateOrders < ActiveRecord::Migration - def self.up + def change create_table :orders do |t| t.datetime :order_date t.string :order_number t.integer :customer_id end end - - def self.down - drop_table :orders - end end </ruby> @@ -451,16 +434,12 @@ These need to be backed up by a migration to create the +assemblies_parts+ table <ruby> class CreateAssemblyPartJoinTable < ActiveRecord::Migration - def self.up + def change create_table :assemblies_parts, :id => false do |t| t.integer :assembly_id t.integer :part_id end end - - def self.down - drop_table :assemblies_parts - end end </ruby> |