我有一个不会通过验证的date_select,即使在表单提交期间所有3个参数都加载了值。我甚至尝试过更改:从日期时间到日期列类型。
<%= f.date_select :birth, :value => @pub.birth, prompt: { day: 'Select birth day', month: 'Select birth month', year: 'Select birth year' }, order: [:day, :month, :year], start_year: 1940, end_year: 1996 %>
模型:
validates :birth, :presence => {:message => "Select your birth date"}
参数:
{"utf8"=>"✓",
"authenticity_token"=>"LLfZGnEXy1kjNWn0p601ys/dvy7qIyRQ6Wj4rIXS7AU=",
"pub"=>{"fname"=>"Jake",
"lname"=>"Mills",
"address1"=>"342 main",
"address2"=>"",
"city"=>"NY",
"zip"=>"10004",
"state"=>"NY",
"birth(3i)"=>"18",
"birth(2i)"=>"11",
"birth(1i)"=>"1957",
"phone"=>"3423426765"},
"commit"=>"Next →"}
答案 0 :(得分:0)
原来问题出在创建动作中。我有以下内容:
pub.birth = params[:pub][:birth]
并将其更改为所有参数的update_attributes。想知道为什么第一种方法不起作用。