# Assign object

**URL:** <https://www.ruby-forum.com/t/assign-object/155818>\
**Category:** Rails\
**Created:** [December 17, 2008, 7:23am UTC](https://www.ruby-forum.com/t/assign-object/155818 "2008-12-17T07:23:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![selva\_rails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e0b2c6/32.png) [@selva\_rails](https://www.ruby-forum.com/u/selva_rails)\
**Post date:** [December 17, 2008, 7:23am UTC](https://www.ruby-forum.com/t/assign-object/155818/1 "2008-12-17T07:23:55Z")

</div>

Hi all,

I am trying to do little bit beyond params… means I try to assign one  
active record object to another object as update attributes both have  
same field. Before that I want to remove id field from old object. Is  
there way to remove attributes from object and to assign new object??

If any one knows…

---

<div class="post-metadata">

**Author:** ![selva\_rails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e0b2c6/32.png) [@selva\_rails](https://www.ruby-forum.com/u/selva_rails)\
**Post date:** [December 17, 2008, 11:13am UTC](https://www.ruby-forum.com/t/assign-object/155818/2 "2008-12-17T11:13:35Z")

</div>

clone() would do that

Returns a clone of the record that hasn‘t been assigned an id yet and  
is treated as a new record. Note that this is a “shallow” clone: it  
copies the object‘s attributes only, not its associations.

---

<div class="post-metadata">

**Author:** ![selva\_rails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e0b2c6/32.png) [@selva\_rails](https://www.ruby-forum.com/u/selva_rails)\
**Post date:** [December 18, 2008, 3:44am UTC](https://www.ruby-forum.com/t/assign-object/155818/3 "2008-12-18T03:44:52Z")

</div>

Thorsten M. wrote:

> clone() would do that
> 
> Returns a clone of the record that hasnï¿½t been assigned an id yet and  
> is treated as a new record. Note that this is a “shallow” clone: it  
> copies the objectï¿½s attributes only, not its associations.

Thanks for you reply…

But I am getting error…

NoMethodError: undefined method `stringify\_keys!’
