# Update database on checkbox update

**URL:** <https://www.ruby-forum.com/t/update-database-on-checkbox-update/141569>\
**Category:** Rails\
**Created:** [June 27, 2008, 5:42am UTC](https://www.ruby-forum.com/t/update-database-on-checkbox-update/141569 "2008-06-27T05:42:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![killy971](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/13edae/32.png) [@killy971](https://www.ruby-forum.com/u/killy971)\
**Post date:** [June 27, 2008, 5:42am UTC](https://www.ruby-forum.com/t/update-database-on-checkbox-update/141569/1 "2008-06-27T05:42:28Z")

</div>

I have search the web for help, with the keywords “rails ajax  
observe\_field update checkbox”, but even using all the things I found,  
I couldn’t really get my application for work properly…  
I think I lack of understanding of ajax and rails interaction with  
ajax.

What I would like to do is very simple.

I have a model “Word”, with the boolean field “important”.  
On the index view, which is listing all the “words”, I would like to  
add a checkbox for each “word”, reflecting the state of the  
corresponding “important” field.

When I change the state of this checkbox (check or uncheck), I would  
like to update (using ajax) the database to change the state of the  
“important” field or the corresponding “word”, with no page change.

The problem is that I don’t know :

- which action (in the words controller) should I call in the :url  
field of the observe\_field helper,
- wether I should add a new action or not in the words controller
- should I render something or not
- should I transmit the “word id” and the “important” state in the  
observe\_field use, and how…

Than you in advance.
