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
@Uri Agassi is right: it's the values that you're passing to create the WorkOrder
that are the most relevant here.
Try putzing around with the custom date formatting options provided to you by bootstrap-datepicker
. If you can get a format that looks good and is easy to parse on the backend, then you'll want to intercept that parameter before it goes to the model for validation.
Regardless of what you'll go with for date formatting on the client-side, you'll still want to parse it into a useable Date
or DateTime
object server-side in your controller. Check out DateTime#strptime. You can also call #strptime
on Date
.
Untested, but the idea is there:
def create
order_params = work_order_params
order_params[:scheduled_date] = Date.strptime(order_params[:scheduled_date],
'%m/%d/%Y %I:%M %p')
@work_order = WorkOrder.new(order_params)
end