I'm trying to render a Date field for my rails model as a datepicker.
The model looks like:
class Appointment
include Mongoid::Document
field :date, type: Date
end
_form.html.haml view looks like:
= form_for @appointment, :url => {:action => :create} do |f|
= f.text_field(:date, {:class => 'datepicker'})
%button{:type => 'submit'} Book appointment
:javascript
jQuery(document).ready(function($) {
$('.datepicker').datepicker();
});
Controller action looks like:
class AppointmentsController < ApplicationController
def create
@appointment = Appointment.new(params[:appointment])
# rest left out for demo purposes
end
end
When "new" gets, called an error occurs:
ArgumentError in AppointmentsController#create
argument out of range
I know the value gets posted as MM/DD/YYYY, i.e. 03/11/2013
How can I tell Rails how to properly serialize this field?