Displaying 1 result from an estimated 1 matches for "fk_products".
Did you mean:
e_products
2006 Jul 18
2
newbie help re: loading data and relationships in migrations
...ns to load in data for
tables that have relationships.
For example, I have one products table and one product_photos table
(defined in separate migration files). The second table has a foreign
key associated with the products table:
execute "alter table product_photos
add constraint fk_products
foreign key (product_id) references products(id)"
The models have the relationships defined:
class Product < ActiveRecord::Base
has_one :product_photo
...
class ProductPhoto < ActiveRecord::Base
belongs_to :product
...
In my data migration file, I create a Prod...