# Implementation checkbox array in rails--How to?

**URL:** <https://www.ruby-forum.com/t/implementation-checkbox-array-in-rails-how-to/163319>\
**Category:** Rails\
**Created:** [March 19, 2009, 8:19am UTC](https://www.ruby-forum.com/t/implementation-checkbox-array-in-rails-how-to/163319 "2009-03-19T08:19:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 19, 2009, 8:19am UTC](https://www.ruby-forum.com/t/implementation-checkbox-array-in-rails-how-to/163319/1 "2009-03-19T08:19:11Z")

</div>

Hi,

```
I am having a nested array like
AVAIL_LISTS = [["Purchased User, 1], ["Downloaded User, 2"]].

In the form i have to allow to check any options applicable
so, in view i have:

```

* * *

```
<% for list in AVAIL_LISTS %>
    <%= form.check_box("lists_selected[]", {}, list[1]) %>
    <%= form.label list[0] %>
<% end %>

=>i guess this should give
<input type="checkbox" name="scheduler[lists_selected][]"

```

value=“1”/\> Purchased User  
 Downloaded User

```
======================================================

I dont have a field column for lists_selected
So, in model i have an attribute accessor like

```

* * *

```
attr_accessor :lists_selected

======================================================

But i am getting an error like,

```

* * *

```
undefined method `lists_selected[]' for #<Scheduler:

```

0x2af2feb5cd88\>

```
======================================================

please suggest, am i going wrong anywhere, i am getting confused

```

with formhelpers docs  
as most of the examples are portrayed with checkbox\_tag

```
Thanks n Regards,
Vimal Das
```

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 19, 2009, 10:21am UTC](https://www.ruby-forum.com/t/implementation-checkbox-array-in-rails-how-to/163319/2 "2009-03-19T10:21:35Z")

</div>

On Mar 19, 7:18 am, vimal [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> please suggest, am i going wrong anywhere, i am getting confused
> 
> ```
> 
> with formhelpers docs  
> as most of the examples are portrayed with checkbox\_tag

You need to use check\_box\_tag for this sort of stuff (the hidden input  
that check\_box generates will mess up array parameters)

Fred

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 19, 2009, 10:25am UTC](https://www.ruby-forum.com/t/implementation-checkbox-array-in-rails-how-to/163319/3 "2009-03-19T10:25:42Z")

</div>

Huh 😑 Thanks very much Fred  
Got it at last… 🙂

Regards,  
VImal Das
