Hi all. I'm importing some legacy data via ActiveRecord. However, it has no primary key and I don't want duplicates - I am reasonably sure the combination of two certain fields are unique, though. What's the best practice & how's it done pls? * Make a string id field and concatenate the two fields (or whatever I want for an ID) in it * Set the two fields to be primary keys, Rails picks it up, and don't use find() * Manually check with find_or_create_by_name_and_date(params) for each record * Something else... Thx!
on 2005-12-27 20:24
on 2005-12-28 14:07
Ah, I forgot to mention that some fields should be referenced by a foreign key. i.e. the data is distinguished by Time & Place and Place is itself a belongs_to. When importing the data, it needs to create new Places - I take it I'd have to use a find_or_create_by_name on the Place object, and then do one of the options below? Sorry, still getting to grips with this.