我的申请已经完成,所以我开始注册。输入信息后,我收到一个错误页面:
UsersController#create 中的 Errno::ECONNREFUSED
Connection refused - {:data=>"<?xml version=\"1.0\" encoding=\"UTF-8\"?><add><doc><field name=\"id\">User 1</field><field name=\"type\">User</field><field name=\"type\">ActiveRecord::Base</field><field name=\"class_name\">User</field><field name=\"username_text\">mikeadeleke</field><field name=\"bio_text\">Founder of Edopter</field></doc></add>", :headers=>{"Content-Type"=>"text/xml"}, :method=>:post, :params=>{:wt=>:ruby}, :query=>"wt=ruby", :path=>"update", :uri=>#<URI::HTTP:0x007fb6c3c911d0 URL:http://localhost:8982/solr/update?wt=ruby>, :open_timeout=>nil, :read_timeout=>nil, :retry_503=>nil, :retry_after_limit=>nil}
消息:
app/controllers/users_controller.rb:14:in `create'
所以这是我的代码导致阻塞。我没有发现任何问题,并通过 roodi 验证器运行了它。
class UsersController < ApplicationController
before_filter :get_user, except: [:new, :create]
def get_user
@user = User.find_by_username(params[:user_name])
end
def new
@user = User.new
end
def create
@user = User.new(params[:user])
if @user.save
sign_in @user
flash[:success] = "Woohoo! Thanks for creating an account. Feel free to edit your profile or look around elsewhere!"
redirect_to(user_url(@user.username))
else
render 'new'
end
end
def show
@resources_upvoted = []
@user.upvotes.where(upvotable_type: "Resource").each do |upvote|
@resources_upvoted << upvote.upvotable
end
@crafts_interested = []
@resources_upvoted.each do |resource|
craft = resource.craft
if !@crafts_interested.include?(craft)
@crafts_interested << craft
end
end
end
def edit
if @user != current_user
redirect_to user_url(@user.username)
end
end
def update
@user.email = params[:email]
@user.bio = params[:bio]
@user.save
redirect_to edit_user_url(params[:user_name])
end
def destroy
@user.destroy
redirect_to home_url
end
end