Showstopper - can't save a record


My big problem comes when attempting to add a payment record. One of the
required fields (validates_presence_of) is TransDate (transaction date).
Even if the user fills that in, they get an error message: TransDate is
missing, and indeed it now appears blank on the screen.

What control are you using for the date entry? Unless you are using
the rails-supplied date_select, there will be some problems,
especially with non-US date formats. What date format are you
expecting? Anyway, if you are using text_field for date entry, if the
date cannot be parsed properly, Date.parse or DateTime.parse (can't
remember which one is used by rails) will silently return nil, which
may explain the error you are seeing.

<more snipped>


One other thing I noticed is that your field names don't follow the
rails naming conventions. Theoretically, this should not be related to
your problem, but try renaming the TransDate field to trans_date and
try that again.


Hi Shauna,

Shauna wrote:

I know the payments_controller create method
is going through the rescue code because it picks
up the following message from the Exception
Mysql::Error: #23000Column 'trans_date' cannot
be null: INSERT INTO...

As I said, that column is not left null on the form
when it is submitted.

When you say "not left null on the form" are you saying you've checked the value of the params hash when the form's submitted to the controller? Or just that the form has had a value entered?

Best regards,

What is the html code generated for the date_select?