Hey all, I''m storing an array of timestamps in a field in my database as an array. When the items get saved, however, some minus signs are appended to the text: sample output: --- - 1151971200 - 1152576000 - 1153180800 - 1153785600 - 1154390400 Is this normal behavior? When I retrive the value out of the database and .to_a, the three minus signs (---) are counted as the first member of the array. This is not what I was wanting (obviously). How do you compensate for that without needing to go there and actually stip it out? Thanks so much! -LW -- Posted via http://www.ruby-forum.com/.
On Friday, June 23, 2006, at 5:33 PM, Luke Wertz wrote:>Hey all, > >I''m storing an array of timestamps in a field in my database as an >array. When the items get saved, however, some minus signs are appended >to the text: > >sample output: >--- >- 1151971200 >- 1152576000 >- 1153180800 >- 1153785600 >- 1154390400 > >Is this normal behavior? When I retrive the value out of the database >and .to_a, the three minus signs (---) are counted as the first member >of the array. This is not what I was wanting (obviously). How do you >compensate for that without needing to go there and actually stip it >out? > >Thanks so much! >-LW > >-- >Posted via http://www.ruby-forum.com/. >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/railsYou want to use ''serialize'' for this.. http://rails.outertrack.com/class/ActiveRecord%3A%3ABase and look for "Saving arrays, hashes, and other non-mappable objects in text columns" a bit down the page _Kevin -- Posted with http://DevLists.com. Sign up and save your mailbox.
Luke Wertz wrote:> Hey all, > > I''m storing an array of timestamps in a field in my database as an > array. When the items get saved, however, some minus signs are appended > to the text: > > sample output: > --- > - 1151971200 > - 1152576000 > - 1153180800 > - 1153785600 > - 1154390400 > > Is this normal behavior? When I retrive the value out of the database > and .to_a, the three minus signs (---) are counted as the first member > of the array. This is not what I was wanting (obviously). How do you > compensate for that without needing to go there and actually stip it > out? > > Thanks so much! > -LWThat''s YAML notation for an array. If you are using "serialize :foo" they should automatically be converted back into an array for you. -- Posted via http://www.ruby-forum.com/.