What Does ActiveRecord::MultiparameterAssignmentErrors Mean?

后端 未结 7 635
[愿得一人]
[愿得一人] 2020-12-15 22:46

I have a rails form with a datetime_select field. When I try to submit the form, I get the following exception:

ActiveRecord::MultiparameterAssignmentErrors          


        
7条回答
  •  攒了一身酷
    2020-12-15 23:38

    Like Zubin I've seen this exception when the form submits a month as a month name rather than a numerical month string (eg. October rather than 10).

    One user agent I've encountered seems to submit the contents of the option tag rather than the value attribute:

    Mozilla/5.0 (SymbianOS/9.2; U; Series60/3.1 NokiaE66-1/300.21.012; Profile/MIDP-2.0 Configuration/CLDC-1.1 ) AppleWebKit/413 (KHTML, like Gecko) Safari/413

    So in the case of submitting a multi-parameter date from a helper generated select (from date_select helper) your params will have:

    "event"=> {
        "start_on(2i)"=>"October",
        "start_on(3i)"=>"19",
        "start_on(1i)"=>"2010"
    }
    

    This creates an exception: ActiveRecord::MultiparameterAssignmentErrors: 1 error(s) on assignment of multiparameter attributes

    Most user agents will correctly submit:

    "event"=> {
        "start_on(2i)"=>"10",
        "start_on(3i)"=>"19",
        "start_on(1i)"=>"2010"
    }
    

提交回复
热议问题