I want to display my houses with a checkbox next to each of them, how do i do it? I know i could do check_box("house[]","enabled") if my houses could be enabled. But what do you do if you just want a list of the ids of the selected houses? Any ideas? I''m sooo sure this is stupidly easy. I feel stupid. I''ve had to do this and it doesnt seem right, although it works: [view] <% for @house in @houses %> <%=check_box "house[]","nil?" %> <% end [controller] #this method will return a list of selected house ids: def get_selected_houses ids=[] params[param].each_pair do |key,value| if value["nil?"]=="1" ids << key end end false end Any ideas what the rails way of doing this is? Thanks Chris -- 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 -~----------~----~----~----~------~----~------~--~---
Francois Beausoleil
2006-Sep-11 16:53 UTC
Re: Select multiple models with multiple checkboxes. Rails Way?
Hello Chris, 2006/9/11, Chris <rails-mailing-list@andreas-s.net>:> I want to display my houses with a checkbox next to each of them, how do > i do it?Look into the MultipleSelect plugin: http://www.agilewebdevelopment.com/plugins/multiple_select_helper http://ruido-blanco.net/blog/rails-multiple-select-helper-plugin/ Hope that helps ! -- François Beausoleil http://blog.teksol.info/ http://piston.rubyforge.org/ --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---