Validating datetime - MultiparameterAssignmentErrors
December 5th, 2007
If you use the date_select, datetime_select helepers you’ll most likely see this error when the user submit an invalid date e.g. (Feb 30). Rails will raise MultiparameterAssignmentErrors.
The easiest way to fix this is by using this plugin for validates_datetime http://agilewebdevelopment.com/plugins/validates_date_time
However I just found that it has a bug with datetime_select, where it parse the (day, hour, minute) into (hour, minute, seconds).
Here is why: on line 179 of validates_date_time.rb in the lib/ folder of the plugin.1 2 3 4 5 6 7 8 |
def extract_time_from_multiparameter_attributes(values) values.last( 3 ).map { |s| s.rjust(2, "0") }.join(":") end # change it to this, it'll fix the problem. def extract_time_from_multiparameter_attributes(values) values.last( values.size > 5 ? 3 : 2 ).map { |s| s.rjust(2, "0") }.join(":") end |

Sorry, comments are closed for this article.