multiparameter error with datetime_select

后端 未结 6 704
傲寒
傲寒 2021-01-02 09:13

I have the following code in my form.

<%= f.datetime_select(:date_time, :prompt => {:day => \'Day\', :month => \'Month\', :year => \'Year\'},          


        
6条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-02 09:40

    What Does ActiveRecord::MultiparameterAssignmentErrors Mean?

    def initialize(attributes={})
      date_hack(attributes, "deliver_date")
      super(attributes)
    end   
    
    def date_hack(attributes, property)
      keys, values = [], []
      attributes.each_key {|k| keys << k if k =~ /#{property}/ }.sort
      keys.each { |k| values << attributes[k]; attributes.delete(k); }
      attributes[property] = values.join("-")
    end
    

提交回复
热议问题