Forum: Ruby on Rails Loading flat-file data into multiple tables

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Michael Y. (Guest)
on 2005-12-28 04:53
(Received via mailing list)
I have a CSV export file with 11 columns that I need to 'split' into
three related tables (some columns go into each table).

	Departments (have many projects)
	Projects (have many audiences)
	Audiences (have many projects)

I understand the model relationships, and have those built.

I am using FasterCSV for file importing and have that iterating
through the CSV rows using a block.

So now I need to 1) understand how to assign the array values to model
objects inside the block; and 2) make sure that the data loaded stays
synchronized. That is, when the 11 columns of the flat file split into
three tables, they need to keep their relations. This seems to require
a multi-table transaction. I am _assuming_ that the foreign keys will
hold it all together.

Am I on the right track here? Can someone provide an example of a
nested transaction that would get me a little further down this path?

Thanks!
-mike
This topic is locked and can not be replied to.