jeudi 16 février 2017

How to save 'Yes' or 'No' instead of 'true' or 'false' with Rails check_box form helper?

I have an object @recipient with attribute responding. Say, I want responding to store "Yes" or "No" via =f.checkbox :responding, {}, 'Yes', 'No', which docs indicate is being possible.

The form submits Yes or No and PostgreSQL UPDATE statement uses Yes or No as expected (I see that in $ rails server terminal window). But - regardless of the responding attribute's data type (boolean or string) - what ends up stored in the db is always true or false. I'm perplexed. What's going on behind the scenes? How can I force Rails to store Yes or No? Should I (not)? Am I misunderstanding something?




Aucun commentaire:

Enregistrer un commentaire