我只将这段代码添加到应用程序中,现在它不允许任何人注册。我收到以下错误:分配多参数属性时出现 1 个错误。错误页面的标题是“ActiveRecord::MultiparameterAssignmentErrors in UsersController#create”。我不确定如何修复,因为不幸的是其他帖子没有帮助。有人有一些解决方案吗?
新的.html.erb:
<div class="field">
<%= f.label :birthday %>
<%= f.date_select :birthday, :start_year => 1995, :end_year => 1930 %>
</div>
用户控制器:
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
开发日志:
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'