I'm creating a form using Ruby Rails. It has a checkbox that when checked denotes the entry should be hidden (true or bit 1. vs false/bit 0), however, when I submit the checkbox I receive an error:
Mysql2::Error: Data too long for column 'hidden_status' at row 1: INSERT INTO `entries` ( 'hidden_status') VALUES (x'30')
The schema for entries and hidden_status
is:
t.binary "hidden_status", limit: 1
The checkbox is:
<%= newEntry.check_box(:hidden_status,{checked:true},1,0)%>
I suspect this has something to do with the datatype being "bit"? However I'm not sure as I'm new to Ruby Rails and from what I looked up BIT is the only way to do a boolean/true vs false value in SQL. Looks like the value is coming up as as x'30'
. Not sure what that means. Is there a way to allow the checkbox to capture 1 or 0?
Also, the parameters in the error shows that the value of the checkbox always returns 0
whether the box is checked or not. Not sure if this is a separate issue or related to the error.
Aucun commentaire:
Enregistrer un commentaire