Dustin James
Dustin James

Reputation: 571

Rails Date Picker Error

I am using the following gem in my rails app - https://github.com/TrevorS/bootstrap3-datetimepicker-rails.

My form looks as follows:

<%= simple_form_for([@customer,@job], html: {class:'form-horizontal'}, wrapper: :horizontal_form) do |f| %>
  <%= f.input :install, collection: ["Yes", "No"], input_html: {class:'form-control'}, prompt: "Installing?" %>
  <%= f.input :delivery, collection: ["Yes", "No"], input_html: {class:'form-control'}, prompt: "Delivering?" %>
  <%= f.input :job_tag, input_html: {class:'form-control'} %>
  <%= f.input :install_date, :as => :date_picker, input_html: { class: "datepicker"} %>    
  <%= f.input :box_count, input_html: {class:'form-control'} %>
  <%= f.input :cabinet_cost, input_html: {class:'form-control'} %>
  <%= f.input :counter_top_cost, input_html: {class:'form-control'} %>
  <%= f.input :install_cost, input_html: {class:'form-control'} %>
  <br />
  <%= f.button :submit, "Create Job", class: "col-md-3 bump-right" %>
<% end %>

When I submit the form I get the following error:

I18n::ArgumentError in Jobs#create 
Object must be a Date, DateTime or Time object. "29/08/2014" given.

Does anyone know why this error is thrown and how I fix this?

Upvotes: 1

Views: 481

Answers (1)

infused
infused

Reputation: 24337

The column in your database for install_date needs to be a date or datetime type. It looks like you are storing the date as a string instead.

Upvotes: 2

Related Questions