我向应用程序添加了这一段代码,现在它不允许任何人注册。我收到以下错误:分配多参数属性时出现1个错误。错误页面的标题是“UsersController#create中的ActiveRecord :: MultiparameterAssignmentErrors”。不幸的是,我不确定如何解决其他帖子无用的问题。任何人有一些解决方案date_select的多参数属性错误
new.html.erb:
<div class="field">
<%= f.label :birthday %>
<%= f.date_select :birthday, :start_year => 1995, :end_year => 1930 %>
</div>
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"=>"[email protected]", "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'
什么是完整的错误? – sevenseacat 2013-03-22 14:40:36
刚刚编辑后的开发日志错误 – pwz2000 2013-03-22 14:48:33
什么数据类型是数据库中的“生日”列? – ramblex 2013-03-22 15:00:19