# Create CheckBox

**URL:** <https://www.ruby-forum.com/t/create-checkbox/165851>\
**Category:** Rails\
**Created:** [April 18, 2009, 9:19am UTC](https://www.ruby-forum.com/t/create-checkbox/165851 "2009-04-18T09:19:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![devirv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9de053/32.png) [@devirv](https://www.ruby-forum.com/u/devirv)\
**Post date:** [April 18, 2009, 9:19am UTC](https://www.ruby-forum.com/t/create-checkbox/165851/1 "2009-04-18T09:19:04Z")

</div>

Hai,

I want to create a checkbox the values are table field values. In my  
controller  
@emptypes = Emptypes.find(:all)  
In View  
\<% @emptypes.each do |c| %\>  
#Write checkbox generating code here  
\<%= check\_box(“contacts”,emptypes.types)%\>  
\<%end%\>  
Anyknows please suggest me how to create a checkbox (values are  
retrived from table).

-with Thanking&Regards  
devi.r

---

<div class="post-metadata">

**Author:** ![devirv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9de053/32.png) [@devirv](https://www.ruby-forum.com/u/devirv)\
**Post date:** [April 18, 2009, 9:41am UTC](https://www.ruby-forum.com/t/create-checkbox/165851/2 "2009-04-18T09:41:46Z")

</div>

Devi Rv wrote:

> Hai,
> 
> I want to create a checkbox the values are table field values. In my  
> controller  
> @emptypes = Emptypes.find(:all)  
> In View  
> \<% @emptypes.each do |c| %\>  
> #Write checkbox generating code here  
> \<%= check\_box(“contacts”,emptypes.types)%\>  
> \<%end%\>  
> Anyknows please suggest me how to create a checkbox (values are  
> retrived from table).
> 
> -with Thanking&Regards  
> devi.r

\<% @emptypes = Emptypes.find(:all)%\>  
\<% @emptypes.each do |c| %\>  
\<%= check\_box “contacts”,“xxxxx”,{},emptypes.types %\>  
in the place of “xxxxx” you have to mention the method name

---

<div class="post-metadata">

**Author:** ![devirv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9de053/32.png) [@devirv](https://www.ruby-forum.com/u/devirv)\
**Post date:** [April 20, 2009, 7:22am UTC](https://www.ruby-forum.com/t/create-checkbox/165851/3 "2009-04-20T07:22:50Z")

</div>

Hi,

I wrote the folling code segment it’s display the labels.  
\<% for emptypes in @emptypes %\>  
\<%= check\_box(“types”, emptypes.id, (@emptypes.include?(emptypes) ?  
{:checked =\> false} : {:checked =\> false} )) %\> \<%= emptypes.types %\>  
\<% end %\>

Thank You for all to given suggestion.

Regards  
devirv

---

<div class="post-metadata">

**Author:** ![devirv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9de053/32.png) [@devirv](https://www.ruby-forum.com/u/devirv)\
**Post date:** [April 20, 2009, 6:32am UTC](https://www.ruby-forum.com/t/create-checkbox/165851/4 "2009-04-20T06:32:26Z")

</div>

Hai,

```
  The check box is created but there is no label for this. How to 

```

print with label. Please suggest me.What we write the  
method(valuesmethod())? In my code is

\<% @emptypes.each do |emptypes| %\>

```
<%= check_box "contacts","valuesmethod",{},emptypes.types %>

```

\<% end %\>

Regards  
devirv
