Hi, I have a serialized attribute in a model: serialize :some_array, Array (I''ve unit tested this attribute and it works just like an Array should.) Now, how do I supply my some_array attribute to my views so that I can reference elements of my array? The following, for example, won''t work: <%= f.text_field :some_array[0] %> Thanks, Lille -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
jspooner-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2010-May-04 14:36 UTC
Re: how to access serialized attributes in my views?
serialize saves the data as yaml so you will have to transform it back to an array. For example I use the to_json method so I can pass the serialized data to JavaScript. On May 3, 6:41 am, Lille <lille.pengu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > I have a serialized attribute in a model: > > serialize :some_array, Array > > (I''ve unit tested this attribute and it works just like an Array > should.) > > Now, how do I supply my some_array attribute to my views so that I can > reference elements of my array? The following, for example, won''t > work: > > <%= f.text_field :some_array[0] %> > > Thanks, > > Lille > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.