This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Ruby and the fly likes Parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Languages » Ruby
Bookmark "Parameters" Watch "Parameters" New topic
Author

Parameters

Rafael Andrade
Greenhorn

Joined: Aug 04, 2006
Posts: 15
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!
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Aug 04, 2006
Posts: 15
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
Rancher

Joined: Sep 29, 2008
Posts: 12617

No problem!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Parameters
 
Similar Threads
How to get Names of selected checkboxes?
How to find Checkboxes?
Dymaically generated forms
retrieving users' bookmarks
How do I maintain the state of checkboxes across page?