# ID and Archiving in Rails

**URL:** <https://www.ruby-forum.com/t/id-and-archiving-in-rails/157333>\
**Category:** Rails\
**Created:** [January 9, 2009, 2:14pm UTC](https://www.ruby-forum.com/t/id-and-archiving-in-rails/157333 "2009-01-09T14:14:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![manohar\_amrutkar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ecd19e/32.png) [@manohar\_amrutkar](https://www.ruby-forum.com/u/manohar_amrutkar)\
**Post date:** [January 9, 2009, 2:14pm UTC](https://www.ruby-forum.com/t/id-and-archiving-in-rails/157333/1 "2009-01-09T14:14:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![manohar\_amrutkar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ecd19e/32.png) [@manohar\_amrutkar](https://www.ruby-forum.com/u/manohar_amrutkar)\
**Post date:** [January 9, 2009, 2:50pm UTC](https://www.ruby-forum.com/t/id-and-archiving-in-rails/157333/2 "2009-01-09T14:50:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![manohar\_amrutkar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ecd19e/32.png) [@manohar\_amrutkar](https://www.ruby-forum.com/u/manohar_amrutkar)\
**Post date:** [January 9, 2009, 3:25pm UTC](https://www.ruby-forum.com/t/id-and-archiving-in-rails/157333/3 "2009-01-09T15:25:01Z")

</div>

Thanks Frederick C. !!!

On Jan 9, 6:49 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
