I'm using Rails 2.3.5 and AR-extensions 0.9.3
I'm trying to bulk insert from one table to another table located on a different server / database. I don't want anything overwritten though. Just a simple insert at the end of the new table is good enough.
I noticed that I get this warning message: WARNING: Can't mass-assign these protected attributes: id
My former entries are being overwritten.. so how do I work around this?
Thanks!
Edit: Figured it out. Looks like all I have to is define an array of attributes I want (Excluding id) and feed that into the import function.
Update:
tableA_items = TableA.find(:all)
TableB.establish_connection("other_server")
TableB.import tableA_items
This bug existed in ar-extensions (up to 0.9.5 in which it was fixed) and activerecord-import (up to 0.2.7 in which it was fixed).
ar-extensions is used for Rails 2.x. activerecord-import should be used for Rails 3.x. They support the same APIs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With