Mass update of associated models

I am importing historical client data from a CODASYL DBMS into
PostgreSQL via an xml document. I am at the point where I am
implementing the actual inserts/updates using ActiveRecord. In the
new system a Client belongs to a Correspondent.

In previous cases I have had to deal with only one model at a time.
In that circumstance I added a class method called ‘load’ to the model
class and passed it an array of hashes each containing the model
attribute keys and values. In this case I have to divide the
information in one xml node into two models.

My question is one of approach. Do I create each associated
Correspondent model inside the Client class load method and parse all
the data there? Or, do I have the controller script parse the data
first, divide the data into two streams, and then call two separate
#loads, one on the Correspondent model and one on the Client model?


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs