Answer the question
In order to leave comments, you need to log in
How to store multiple values from multi checkbox in 1 field of string type database?
It is necessary to store several values from the checkbox with multiple selection in a database field of type string
<input id="checkbox-1" type="checkbox" value="drama" name="user[book][]">
<input id="checkbox-2" type="checkbox" value="poem" name="user[book][]">
<input id="checkbox-3" type="checkbox" value="tragicomedy" name="user[book][]">
private
def user_params
params.require(:user).permit(.....)
end
Answer the question
In order to leave comments, you need to log in
Without irony, I say that you formulated the question so competently that you answered yourself. Cast user[book] to the string you want and save.params.requier(:user).permit(:your_string_field)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question