I’m having some issues with sumitting forms and rails detecting the entries as valid. For example, if someone leaves the field ’email’ blank and submits, <% if @user.email %> would return true, even though it’s technically blank.
Is there a way to either keep the NULL value in the database if the form field is blank or is there an alternative to <% if @user.email %> that I can use to detect if physical characters are present in a field?
Thanks!
You should be checking for
blank?:Always
If no entry has been made in the form then the params would return null for that field when posted to the controller action and the field will be left as is in the table.
I suspect you have another issue but the above will solve your symptoms. The trick is to get to the cause and only a stack trace from your log file will show you what is going on plus some investigation in the table data directly.