# How to write a bloc in helper to check/uncheck box?

**URL:** <https://www.ruby-forum.com/t/how-to-write-a-bloc-in-helper-to-check-uncheck-box/129123>\
**Category:** Rails\
**Created:** [February 14, 2008, 5:49pm UTC](https://www.ruby-forum.com/t/how-to-write-a-bloc-in-helper-to-check-uncheck-box/129123 "2008-02-14T17:49:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [February 14, 2008, 5:49pm UTC](https://www.ruby-forum.com/t/how-to-write-a-bloc-in-helper-to-check-uncheck-box/129123/1 "2008-02-14T17:49:15Z")

</div>

Hi all

I have a check box in form, and I would like to enable/disable it  
according to the value of the check box…

\<% form\_for(:query, @query,…

\<%= f.check\_box(:all\_categories, :disabled =\> true, :onchange  
=\>‘javascript:all\_categories();’) -%\>\<%=l :All\_categories %\>

I would like to have something like :disabled =\> {  
@query.all\_categories.to\_i == 1}  
which will be evaluated as true or false  
but I cannot write it , get into error…

any suggestion ?

thanks a lot
