Rails: How to toggle a boolean field from a view?

Posted by sscirrus on Stack Overflow See other posts from Stack Overflow or by sscirrus
Published on 2010-06-13T03:45:07Z Indexed on 2010/06/13 3:52 UTC
Read the original article Hit count: 226

Very simple question.

I have a boolean field called "saved" in my database. I want to toggle this field by clicking on a text link that changes from "Save" to "Unsave" depending on the situation, and updates my "Customer" table with 0 or 1. I imagine Javascript may be a way to go for this but I am not experienced enough (yet!) in Javascript to know how to code it.

What is the best way to approach this problem, and how can I find the code I would need to drop into my view to make this toggle work? Thank you very much.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about ruby-on-rails