tyliong
2008-Dec-18 11:13 UTC
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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Dec-18 11:19 UTC
Re: serializing active record objects do not save after first slice
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> please help. > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Tan YL
2008-Dec-18 11:35 UTC
Re: serializing active record objects do not save after first slice
Thanks Fred! That worked! -----Original Message----- From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of Frederick Cheung Sent: Thursday, December 18, 2008 7:20 PM To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Subject: [Rails] Re: serializing active record objects do not save after first slice 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> please help. > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---