vendredi 24 juillet 2020

ruby on rails - HTML checkbox that changes ruby boolean

Ok, so I'm trying to do something quite simple in my eyes, but I can't figure it out.

I have a ruby on rails app and in one of the views I'm trying to create a checkbox that sets a boolean to either true or false with onclick (so I don't want to use a submit button of any kind). The thing is I want to be able to access this boolean as a ruby variable in the view.

I've tried using a form_tag and a check_box_tag to pass it to the controller via the params[] and then passing it to the view, but I didn't get it to work. I also tried just doing it by making an HTML input and some javascript, but got stuck again.

Anyone have any idea how I can do this. I don't really care how it's done as long as it works. Of course if there some kind of 'ruby way' to do this I would love to know.




Aucun commentaire:

Enregistrer un commentaire