我在使用Rails的日期帮手表单提交失败多于一个date_select帮手的Rails 3
date_select
麻烦,如果我只有一个形式,然后形式完美地提交到数据库,但如果另我date_select帮手标记添加到我的形式,然后我收到以下错误:
ActiveRecord::MultiparameterAssignmentErrors in Admin::StudentRegistrationsController#create
1 error(s) on assignment of multiparameter attributes
我的控制器是通常的支架之一:
# POST /student_registrations
# POST /student_registrations.xml
def create
@student_registration = StudentRegistration.new(params[:student_registration])
respond_to do |format|
if @student_registration.save
format.html { redirect_to(@student_registration, :notice => 'Student registration was successfully created.') }
format.xml { render :xml => @student_registration, :status => :created, :location => @student_registration }
else
format.html { render :action => "new" }
format.xml { render :xml => @student_registration.errors, :status => :unprocessable_entity }
end
end
end
,我的看法如下:
<%= form_for([:admin, @student_registration]) do |f| %>
<div class="reg_title">
Date of Birth
</div>
<div class="reg_content">
<%= f.date_select(:DOB,:start_year => 1940) %>
</div>
<div class="reg_title">
Passport Expiry Date
</div>
<div class="reg_content">
<%= f.date_select(:PPortE,:start_year => 1940) %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
在我的PARAMS日期走到一起,所以没有空白:
"DOB(1i)"=>"1979", "DOB(2i)"=>"9", "DOB(3i)"=>"4", "PPortE(1i)"=>"2012", "PPortE(2i)"=>"1", "PPortE(3i)"=>"4"},
但是,如果我再次注释掉护照EXP date_select休息的表格将提交。任何想法,将不胜感激
今天我有同样的问题。我注意到这个问题促使我看看我的迁移 - 我把date_of_birth作为一个:字符串而不是:date。感谢您解决您自己的查询! – LpLrich 2013-11-20 14:22:51