views:

131

answers:

1

I have a fasterCSV rake script but it only imports to 1 table. I am importing products and the products have several pieces of info stored on other tables.

Current script: http://gist.github.com/321889

What I need to add is some way to import product info to another table at the same time. Say a category name.

In this case: the rows

  product.name = row[2]
  product.available_on = Time.now
  product.description = row[3]
  product.vendor_sku = row[12]
  product.price = row[13]#.to_d
  product.save(false)

I need an item like taxon.name = row[14]

is this possible?

A: 

Try something like:

associated_category = Category.find_by_name(row['Category'])
Produkt.create(
        :category_id => associated_category.id,
        :name => row[2]
        )

I do it that way: http://gist.github.com/324613

Harm

Harm