How to assign a non-auto ID?

On Dec 13, 2007, at 12:42 PM, Sam K. wrote:

I know I can copy the database.
But the structures are so different that I can’t just copy and paste.
Also, I need to apply complex rules.
That’s why I need to use ActiveRecord.

I hope that I explained my intention well.:slight_smile:

Sam

If you assign the id ‘manually’, it will be honored, if possible.

mycopy = Model.new(hash_of_old_attributes) { |m| m.id = oldid }

… apply complex rules …

mycopy.save

Note that you can’t have :id in the hash_of_old_attributes (well, it
will be ignored if present).

-Rob

(of course, you’re on the forum and may never see this message…)

Rob B. http://agileconsultingllc.com
[email protected]