I'm getting a weird error I don't understand. It seem that when I try to create a new model object, something about the params is being passed are being as symbol and I can't do anything with them.
The error I'm getting is:
can't convert Symbol into Integer
The controller action is:
def create
user_info = :params[:user]
if !user_info.value? ""
if user_info[:password] == user_info[:password2] and user_info[:email] == user_info[:email2]
user_info.delete("password2")
user_info.delete("email2")
@user = User.create!(user_info)
@user = User.new(user_info)
respond_to do |format|
if @user.save
format.html { redirect_to(@user, :notice => 'User was successfully created.') }
else
format.html { render :action => "new" }
end
end
end
flash[:warning] = "Please try again"
redirect_to home_index_path
end
I'm trying to submit attributes with "", but I get this error. When I removed the indicated problem line user_info = :params[:user]
and changed everything in terms of :params[:user]
it still threw the error and indicated the next line as the problem.
Can anyone see why?
Turn
user_info = :params[:user]
to:
user_info = params[:user]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.