我在我的rails应用程序中使用以下gem - https://github.com/TrevorS/bootstrap3-datetimepicker-rails。
我的表格如下:
<%= 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 %>
当我提交表单时,我收到以下错误:
I18n::ArgumentError in Jobs#create
Object must be a Date, DateTime or Time object. "29/08/2014" given.
有谁知道为什么会抛出这个错误以及我如何解决这个错误?
答案 0 :(得分:2)
数据库中install_date
的列必须是date
或datetime
类型。看起来您将日期存储为字符串。