Topic: Migration: loading fixture for HABTM tables

Les say I have two tables (brands & products) linked with a HABTM table.

In my migration files, I can use this code to load data in them:

    f = Fixtures.new(Brand.connection, # a database connection
                     "brands", # table name
                     Brand, # model class
                     File.join(File.dirname(__FILE__), "dev_data/brands"))
    f.insert_fixtures

But I dont see how I can load the code that loads the fixture with the data linking the two table because it require a model and  there are none, just the table "brands_products".

How can I do this?

Thanks!

Re: Migration: loading fixture for HABTM tables

Untested, but try this in your migration:

f = Fixtures.new(Brand.connection, # a database connection 
                 "brands_products", # table name
                 nil, # model class
                 File.join(File.dirname(__FILE__), "dev_data/brands_products"))
f.insert_fixtures

Last edited by ryanb (2006-08-07 13:30:44)

Railscasts - Free Ruby on Rails Screencasts