On Mon, Sep 5, 2011 at 9:32 PM, Gregory Ma
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:
> Hi,
>
> I have a model with an attribute called "degrees". This attribute
is
> serialized. The attribute has to store an array like this:
> ["degree1", "degree"]
>
> My question is, how can I do this in my form?
>
> I have done this but I only get the last element
> <% form @obj do |f| %>
> <%=f.check_box :degree, "degree1" %>
> <% end %>
>
>
i''m assuming you have a list of degrees which the user can check.
upon submitting the form, you want params[:obj][:degree] to be
an array with values equal to the checked degrees. if that''s right
then you need to use check_box_tag
<% [''degree1'', ''degree2'',
''degree3''].each do |degree| %>
<%= check_box_tag ''obj[degree][]'', degree %>
<% end %>
ch
> Greg
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> 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.
>
>
--
-------------------------------------------------------------
visit my blog at http://jimlabs.heroku.com
--
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.