# Array unshift and save to database

**URL:** <https://www.ruby-forum.com/t/array-unshift-and-save-to-database/170738>\
**Category:** Rails\
**Created:** [June 22, 2009, 10:26am UTC](https://www.ruby-forum.com/t/array-unshift-and-save-to-database/170738 "2009-06-22T10:26:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gpierce](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/90ced4/32.png) [@gpierce](https://www.ruby-forum.com/u/gpierce)\
**Post date:** [June 22, 2009, 10:26am UTC](https://www.ruby-forum.com/t/array-unshift-and-save-to-database/170738/1 "2009-06-22T10:26:16Z")

</div>

Hello,

I’ve noticed that I can’t save my object to the DB after using ‘unshift’  
on one of Array fileds. Ex:

(below ‘tags’ is a collection in object ‘transaction’)

transaction.tags.unshift(Tag.find\_or\_create\_by\_name(name))  
transaction.save!

Everything is fine when I am using ‘\<\<’ to append tag to array.

Regards
