# Serializing active record objects do not save after first slice

**URL:** <https://www.ruby-forum.com/t/serializing-active-record-objects-do-not-save-after-first-slice/155946>\
**Category:** Rails\
**Created:** [December 18, 2008, 12:13pm UTC](https://www.ruby-forum.com/t/serializing-active-record-objects-do-not-save-after-first-slice/155946 "2008-12-18T12:13:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tyanlion](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f0a364/32.png) [@tyanlion](https://www.ruby-forum.com/u/tyanlion)\
**Post date:** [December 18, 2008, 12:13pm UTC](https://www.ruby-forum.com/t/serializing-active-record-objects-do-not-save-after-first-slice/155946/1 "2008-12-18T12:13:31Z")

</div>

Hi,

i am having a very weird problem i have an array

Model:

serialize :marketarray

Controller  
@marketobject = Market.find(1)

@marketobject.marketarray = [“red”,“blue”,“green”]

I do this @marketobject.marketarray.slice!(0)

@marketobject.save!

but it does not change the Market.marketarray to [“blue”,“green”]

it just keeps the original array as if it did not happen

if i do this @marketobject.marketarray = [“1”,“1”]  
@marketobject.save!  
then it saves the marketarray to [“1”,“1”]

please help.

---

<div class="post-metadata">

**Author:** ![tyanlion](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f0a364/32.png) [@tyanlion](https://www.ruby-forum.com/u/tyanlion)\
**Post date:** [December 18, 2008, 12:20pm UTC](https://www.ruby-forum.com/t/serializing-active-record-objects-do-not-save-after-first-slice/155946/2 "2008-12-18T12:20:33Z")

</div>

On 18 Dec 2008, at 11:13, tyliong wrote:

> but it does not change the Market.marketarray to [“blue”,“green”]
> 
> it just keeps the original array as if it did not happen
> 
> if i do this @marketobject.marketarray = [“1”,“1”]  
> @marketobject.save!  
> then it saves the marketarray to [“1”,“1”]

call @marketobject.marketarray\_will\_change! before you save (you must  
do this when you change objects in place (so same thing if you had a  
string attribute and did .gsub!)

Fred

---

<div class="post-metadata">

**Author:** ![tyanlion](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f0a364/32.png) [@tyanlion](https://www.ruby-forum.com/u/tyanlion)\
**Post date:** [December 18, 2008, 12:25pm UTC](https://www.ruby-forum.com/t/serializing-active-record-objects-do-not-save-after-first-slice/155946/3 "2008-12-18T12:25:50Z")

</div>

Thanks Fred! That worked!
