Is it guaranteed that if you submit a form to a Rails action, and you
have a text field with no data in it, that the resulting entry in the
params hash for that text field will have value ‘’ (empty string)
instead of nil?
I seem to have one page that submits one way (param is ‘’) and another
the other way (param is nil).
One page was doing a POST and the other was doing a GET (because I had
some fancy-assed Javascript submitting my form and I assumed that I
could just get away with a plain tag in my page, not realizing
that the method for the form submission would default to GET). Once I
changed the form in the 2nd page to do a POST, all the behavior was
consistent.
Sigh.
But…the good news is that now I know that a text field in a form which
doesn’t get any text typed into it will show up as nil in params if you
do a GET and as ‘’ in params if you do a POST.
One page was doing a POST and the other was doing a GET (because I had
some fancy-assed Javascript submitting my form and I assumed that I
could just get away with a plain tag in my page, not realizing
that the method for the form submission would default to GET). Once I
changed the form in the 2nd page to do a POST, all the behavior was
consistent.
Sigh.
But…the good news is that now I know that a text field in a form which
doesn’t get any text typed into it will show up as nil in params if you
do a GET and as ‘’ in params if you do a POST.
I’m glad I found it - I was starting to go mad.
Wes
If you are only starting to go mad now, then how did you become a
programmer in the first place?