rails reject_if for time fields

123 Views Asked by At

sorry for my english, my question is: how can I check empty time fields on reject_if block. Here is a bit of my code.

accepts_nested_attributes_for :working_times, :allow_destroy => true, :reject_if => proc { |attributes| attributes[:start_time].blank? }

But this is not working because attributes[:start_time] is not blank when I didn't select a time on select field, rather, is...

{"start_time(1i)"=>"1", "start_time(2i)"=>"1", "start_time(3i)"=>"1", "start_time(4i)"=>"", "start_time(5i)"=>"", "stop_time(1i)"=>"1", "stop_time(2i)"=>"1", "stop_time(3i)"=>"1", "stop_time(4i)"=>"", "stop_time(5i)"=>""}

how is the best way to validate a time field

Thanks in advance, Regards.

0

There are 0 best solutions below