When I select blank in the UI dropdown component and post the form, the
validation succeeds and when the form is redisplayed ‘No’ is selected in
the dropdown. I see that in the database (MySQL) attending column,
false gets saved in that column.
How do I make validation to fail when blank is selected in the dropdown.
When I select blank in the UI dropdown component and post the form, the
validation succeeds and when the form is redisplayed ‘No’ is selected in
the dropdown. I see that in the database (MySQL) attending column,
false gets saved in that column.
How do I make validation to fail when blank is selected in the dropdown.
thanks,
I’m beginning to think it has to do with with the Model field’s (i.e
‘attending’ in guest.rb) mapping to the MySQL column (“attending”) which
is declared in the schema as:
(attending tinyint(1) unsigned default NULL)
I have tried debugging the code but can’t seem to find the source of
this problem. Any ideas?
If I use validate_presence_of then it the field is only considered valid
if ‘Yes’ (true) is selected. Selecting ‘No’ (false) results in
validation error.
After some reading this is what I found which is why I chose to use
validate_presence_of:
“If you want to validate the presence of a boolean field (where the real
values are true and false), you will want to use validates_inclusion_of
:field_name, :in => [true, false] This is due to the way Object#blank?
handles boolean values. false.blank? # => true”
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.