Serializing active record objects do not save after first slice

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.

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

Thanks Fred! That worked!