vendredi 16 avril 2021

Rails custom model validator depending on check_box value

Lets say i have a model "Blog" with :title and :body. Lets also say that in my view I have input for title, body and a check_box_tag that looks like this

<%= check_box_tag "published" %>

Now, I want to write a custom validation for the :body that should run only if my checkbox "published" is checked.

The question is - how do i get the value of the ckeckbox since :published is not a model attribute?




Aucun commentaire:

Enregistrer un commentaire