• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Parameters

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello guys.
I have a page with some checkboxes, and the ones that are checked are coming in the parameters list, with the name & ID. I wanted to receive the data in an Array inside params Hashmap, so I can iterate not having to worry about the other parameters, like action, method, etc.
I'm creating the checkboxes this way:
<%= check_box_tag "#{category.name}", category.id, category.active %>

Anyone know the trick?
Thanks alot.
BTW, was very happy to find out that javaranch has a RoR section!
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not entirely sure what you're asking, but if you want to receive parameters in an array, you need to use array naming notation on the view side, like is done in this tutorial:

http://satishonrails.wordpress.com/2007/06/29/multiple-checkboxes-with-habtm/

Does that answer your question? (It also covers using it with an habtm relationship, which may be more information that you needed.)
 
Rafael Andrade
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi man!
Thanks for the reply. That's exactly what I was looking for.
So, the solution is something like this:

<%= check_box_tag "category[#{category.name}]", category.id, category.active %>

We have to pass an array in the first parameter.

Thanks alot.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No problem!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic