Monday, April 12, 2010

Rails built in Date parsing fixes

Rails(2.3.5) date parsing is busted IMO.

Try this: Place a date_select that allows blanks into a form and then enter the date 2010, "", 31 -- IE no month and the day 31 and submit the form. The result is a crash from a MultiparameterAssignmentErrors exception.

I dont care why it was does it.. to me its wrong here is the fix;


module ActiveRecord
  class Base
    def assign_multiparameter_attributes(pairs)
      begin
        execute_callstack_for_multiparameter_attributes(
        extract_callstack_for_multiparameter_attributes(pairs))
      rescue  MultiparameterAssignmentErrors => e
        e.errors.each { |err|
          self.errors.add(err.attribute)
        }
      end
    end
  end
end

No comments:

Post a Comment