# Checkboxes across multiple objects

**URL:** <https://www.ruby-forum.com/t/checkboxes-across-multiple-objects/126514>\
**Category:** Rails\
**Created:** [January 18, 2008, 10:08pm UTC](https://www.ruby-forum.com/t/checkboxes-across-multiple-objects/126514 "2008-01-18T22:08:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mark](https://www.ruby-forum.com/u/mark)\
**Post date:** [January 18, 2008, 10:08pm UTC](https://www.ruby-forum.com/t/checkboxes-across-multiple-objects/126514/1 "2008-01-18T22:08:59Z")

</div>

So I have a list of jobs which I show like this. (cleaned up…)

\_list.rhtml

\<% for job in @jobs %\>

\<% end %\>

I want checkboxes next to each and every job name and a button or link  
somewhere else on the page to “delete selected”, “publish selected” ,  
and “unpublish selected”

I have seen the RailsCast which does this, but it uses REST and I am  
not using REST and am confused.

Can anyone help?

I need the data of the checkboxes in the controller. Just not sure how  
to get it.

I am pretty sure I want something like this in the view.

But don’t know what the form header or submit buttons should look like  
to get me the data in the controller.

```
Reply Reply to author Forward
```

| \<%= job.name %\> |
| \<%= check\_box\_tag "job\_ids[]", job.id %\> |

---

<div class="post-metadata">

**Author:** ![mark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mark](https://www.ruby-forum.com/u/mark)\
**Post date:** [January 18, 2008, 10:24pm UTC](https://www.ruby-forum.com/t/checkboxes-across-multiple-objects/126514/2 "2008-01-18T22:24:20Z")

</div>

Hi,

You are right about the checkbox; it should look something like that.  
I believe the correct form is:  
\<%= check\_box(“job\_ids”, jod.id) %\>  
Then you just use an old school form(on top of my head):  
\<%- form\_tag :controller =\> ‘foo’, :action =\> ‘bar’ do -%\>  
\<%= check\_box(“job\_ids”, jod.id) %\>  
\<%= submit\_tag(“Go”)  
\<%- end -%\>  
But I might be sadly mistaken. 😉

With kind regards,  
Harm

---

<div class="post-metadata">

**Author:** ![mark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mark](https://www.ruby-forum.com/u/mark)\
**Post date:** [January 19, 2008, 10:36pm UTC](https://www.ruby-forum.com/t/checkboxes-across-multiple-objects/126514/3 "2008-01-19T22:36:45Z")

</div>

Yea, not so much.

I need to then access the data in the controller.

And I want to be able to do different things to the data based on  
three different (Links or Submit Buttons)

---

<div class="post-metadata">

**Author:** ![mark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mark](https://www.ruby-forum.com/u/mark)\
**Post date:** [January 21, 2008, 9:40am UTC](https://www.ruby-forum.com/t/checkboxes-across-multiple-objects/126514/4 "2008-01-21T09:40:41Z")

</div>

On Jan 19, 10:36 pm, Mark [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Yea, not so much.
> 
> I need to then access the data in the controller.

But you can pull that from the params right? params[:job\_ids] is an  
array of ids.

> And I want to be able to do different things to the data based on  
> three different (Links or Submit Buttons)

In that case you can look at the params[:commit] value.

---

<div class="post-metadata">

**Author:** ![mark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9c0ed/32.png) [@mark](https://www.ruby-forum.com/u/mark)\
**Post date:** [January 21, 2008, 2:40pm UTC](https://www.ruby-forum.com/t/checkboxes-across-multiple-objects/126514/5 "2008-01-21T14:40:57Z")

</div>

Ok.

So I finally got that working.

Parameters: {“commit”=\>“delete selected”, “job\_ids”=\>[“1632”, “1633”,  
“1634”], “action”=\>“updateselected”, “controller”=\>“jobs”}

I can access the Ids no problem from the controller.

Now the only thing I would like to do is make these “links” instead of  
“submit buttons” to make the app look a little better.

I want to either have three links [Delete Selected, Publish  
Selected, UnPublish Selected]

Or do a Drop down like Gmail does for the actions availble when I  
select a bunch of emails.

Can anyone help with that?

Right now all I have in the view is

\<%= submit\_tag ‘delete selected’%\>  
\<%= submit\_tag ‘publish selected’%\>  
…

Thanks,  
Mark
