Hi, I am having a nested array like AVAIL_LISTS = [["Purchased User, 1], ["Downloaded User, 2"]]. In the form i have to allow to check any options applicable so, in view i have: -------------------------------------------------------------------------------------- <% for list in AVAIL_LISTS %> <%= form.check_box("lists_selected[]", {}, list[1]) %> <%= form.label list[0] %> <% end %> =>i guess this should give <input type="checkbox" name="scheduler[lists_selected][]" value="1"/> Purchased User <input type="checkbox" name="scheduler[lists_selected][]" value="2"/> Downloaded User ===================================================== I dont have a field column for lists_selected So, in model i have an attribute accessor like -------------------------------------------------------------------------------------- attr_accessor :lists_selected ===================================================== But i am getting an error like, -------------------------------------------------------------------------------------- undefined method `lists_selected[]'' for #<Scheduler: 0x2af2feb5cd88> ===================================================== please suggest, am i going wrong anywhere, i am getting confused with formhelpers docs as most of the examples are portrayed with checkbox_tag Thanks n Regards, Vimal Das --~--~---------~--~----~------------~-------~--~----~ 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
2009-Mar-19 09:20 UTC
Re: Implementation checkbox array in rails--How to?
On Mar 19, 7:18 am, vimal <cool.vimalsm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > please suggest, am i going wrong anywhere, i am getting confused > with formhelpers docs > as most of the examples are portrayed with checkbox_tag >You need to use check_box_tag for this sort of stuff (the hidden input that check_box generates will mess up array parameters) Fred> Thanks n Regards, > Vimal Das--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Huh :-| Thanks very much Fred Got it at last... :-) Regards, VImal Das --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---