date_select的多参数属性错误

我在应用程序中添加了这一段编码,现在它不允许任何人注册。 我收到以下错误:1个错误分配多参数属性。 错误页面的标题是“UsersController #create中的ActiveRecord :: MultiparameterAssignmentErrors”。 我不知道如何解决,因为其他post不幸没有帮助。 有人有一些解决方案?

new.html.erb:

1995, :end_year => 1930 %>

users_controller:

 def create @user = User.new(params[:user]) if @user.save UserMailer.registration_confirmation(@user).deliver session[:user_id] = @user.id redirect_to root_url, notice: "Thank you for signing up!" else render "new" end end 

development.log:

 Started POST "/users" for 127.0.0.1 at 2013-03-22 10:27:31 -0400 Processing by UsersController#create as HTML Parameters: {"utf8"=>"✓", "authenticity_token"=>"7KAgvcc6yvuhKQGNrJo8UpfsUyuNG16TuMsRj6qst48=", "user"=>{"email"=>"james@james.com", "password"=>"[FILTERED]", "username"=>"james", "zip_code"=>"84784", "gender"=>"women", "age"=>"23", "age_end"=>"39", "birthday(1i)"=>"1995", "birthday(2i)"=>"3", "birthday(3i)"=>"22", "role"=>"admin"}, "commit"=>"Create User"} Completed 500 Internal Server Error in 100ms ActiveRecord::MultiparameterAssignmentErrors (1 error(s) on assignment of multiparameter attributes): app/controllers/users_controller.rb:18:in `new' app/controllers/users_controller.rb:18:in `create' 

实际问题是数据库中的值是在VARCHAR上,而应该是DATE。 现在它工作正常。

首先确保生日的类型应为Date

在参数中, 生日的值如下所示。

 "birthday(1i)"=>"1995", "birthday(2i)"=>"3", "birthday(3i)"=>"22" 

但字段ID的类型为Date 。 所以我认为,在更新生日字段之前,我们需要生成适当的日期对象,然后需要更新对象。

 @user.birthday = Date.strptime("#{params['birthday(3i)']}/#{params['birthday(2i)']}/#{params['birthday(1i)']}", "%d/%m/%y") 

现在保存对象,希望这次不会引发任何错误。

如果仍有错误,请告诉我。