1

I'm having trouble validating date fields using date_select helper from form_builder, whenever one of the parameters is left blank (e.g year params). I'm using the validates_timeliness gem and it works perfectly with datetime_select however it doesn't work on date_select.

on my model class I do have this validation:

validates_date :start_date, on_or_before: :today, allow_blank: true

this is the field on the view (uses simple_form)

= f.input :start_date

and this are the parameters (start_date(1i) is for year params and was left blank):

"start_date(1i)"=>"",
"start_date(2i)"=>"2",
"start_date(3i)"=>"3"

and this is what I got after submitting it

1 error(s) on assignment of multiparameter attributes [error on assignment [nil, 2, 3] to start_date (undefined method `<' for nil:NilClass)]

Hope somebody can help me out with this. Thank you in advance.

  • I don't observe this behavior with the `validates_timeliness` gem - it simply sets the whole date to `nil`. Can you provide the stack trace (the first few lines should do)? – Matouš Borák May 04 '16 at 17:36

0 Answers0