I have been struggling to get some check boxes working but have had absolutely no luck. Can someone tell me what I am doing wrong. Any help would be greatly appreciated. Here is the code in my view: <% for size in @sizes %> <%= f.check_box(''size_list[]'', size, @item.sizes.collect {|size| size.id}.include?(size.id)) %><%=h size.name %><br /> <% end %> Here is the code in my controller: @brands = Brand.find :all @sizes = Size.find :all @categories = Category.find :all @item = Item.find(params[:id]) The error I get is: Showing items/edit.html.erb where line #15 raised: undefined method `check_box_tag'' for #<ActionView::Helpers::FormBuilder:0x7f5ca4ed2e90> -- 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-/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 -~----------~----~----~----~------~----~------~--~---
PS: I''ve tried it with check_box_tag and check_box both. -- 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-/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 -~----------~----~----~----~------~----~------~--~---
<...>> Here is the code in my view: > > <% for size in @sizes %> > <%= f.check_box(''size_list[]'', size, @item.sizes.collect {|size| > size.id}.include?(size.id)) %><%=h size.name %><br /> > <% end %>Is that all code in the view, or do you have form_for here also? Regards, Rimantas -- http://rimantas.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-/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 -~----------~----~----~----~------~----~------~--~---
Here is the entire view as I have it now. I did manage to get the check boxes to show up finally but once you submit the form and come back to the view again to check that the information was saved correctly they are all messed up. For example I have three sizes in my database (10,11, and 12) and the first time you view the form these are the three options shown but if you select anyof the and submit the form when you refresh the form they all three have the same label (12 in my case). I''m just plain confused here. <h1>Editing item</h1> <%= error_messages_for :item %> <% form_for @item, :html => { :multipart => true } do |f| %> <p> <b>Brand</b><br /> <%= f.select :brand_id, @brands.collect {|brand| [brand.name, brand.id]} %> </p> <p> <b>Sizes</b><br /> <% for size in @sizes %> <%= check_box_tag(''size_list[]'', size.id, @item.sizes.collect {|size| size.id}.include?(size.id)) %><%=h size.name %><br /> <% end %> </p> <p> <b>Category</b><br /> <%= f.select :category_id, @categories.collect {|category| [category.name, category.id]} %> </p> <p> <b>Picture</b><br /> <%= f.file_field :picture %> </p> <p> <b>Price</b><br /> <%= f.text_field :price %> </p> <p> <b>Name</b><br /> <%= f.text_field :name %> </p> <p> <b>Description</b><br /> <%= f.text_area :description %> </p> <p> <%= f.submit "Update" %> </p> <% end %> -- 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-/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 -~----------~----~----~----~------~----~------~--~---