Argument out of range Rails 4 and bootstrap3-datetimepicker-rails

后端 未结 4 743
隐瞒了意图╮
隐瞒了意图╮ 2021-02-07 08:29

I\'m using the bootstrap3-datetimepicker-rails gem to let users store the scheduled_date of a WorkOrder in my application (a \'DateTime\' property), bu

4条回答
  •  情话喂你
    2021-02-07 09:20

    You can remove the modifications from the Controller all together by updating the values in the model. I feel this is a much cleaner (and reusable) approach.

    class Work < ActiveRecord::Base
    
      def scheduled_date=(date)
         begin
           parsed = Date.strptime(date,'%m/%d/%Y %I:%M %p')
           super parsed
         rescue
           date         
         end
      end
    
    end
    

提交回复
热议问题