Forum: Ruby on Rails ID and Archiving in Rails

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.
manohar amrutkar (Guest)
on 2009-01-09 15:14
(Received via mailing list)
Hi All,

I have created a table "record_archives" using engine=archive in my
application to archive data for a table "records". I want to insert
data into archived table at specific time, like once in a week. I have
created model for that table but not used any migration and directly
created a table using script. The script includes default value for id
is ZERO and Initially there is not a single entry in both tables.

When i creates a record using RecordArchive.create(:id=>rec.id, ...),
it inserts ZERO into archive table even though  i have passed an id
for that record.

And i am not sure why it doesn't insert the value for id into archived
table?

Please somebody can answer my question, How to insert the value for
id? Is there any other way to insert the actual value of ID? Do i need
to use any other way to insert the data into archived table as Rails
models may be using index and which is not supported in archive
engine?

Thanks,
Manohar.
Frederick C. (Guest)
on 2009-01-09 15:50
(Received via mailing list)
On 9 Jan 2009, at 13:14, manohar amrutkar wrote:

> When i creates a record using RecordArchive.create(:id=>rec.id, ...),
The id column is protected from mass assignment. At the very least
you'd have to do something like
foo = Foo.new
foo.id = 123
foo.save!

Fred
manohar amrutkar (Guest)
on 2009-01-09 16:25
(Received via mailing list)
Thanks Frederick C. !!!

On Jan 9, 6:49 pm, Frederick C. <removed_email_address@domain.invalid>
This topic is locked and can not be replied to.