ruby on rails - Errno::ECONNREFUSED in UsersController#create -
my application proceeded register. after input information receive error page saying:
errno::econnrefused in userscontroller#create
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}
the message:
app/controllers/users_controller.rb:14:in `create'
so here code causing hold up. see no issues , ran through roodi validator.
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! creating account. feel free edit profile or around elsewhere!" redirect_to(user_url(@user.username)) else render 'new' end end def show @resources_upvoted = [] @user.upvotes.where(upvotable_type: "resource").each |upvote| @resources_upvoted << upvote.upvotable end @crafts_interested = [] @resources_upvoted.each |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
your db connection fine, in fact, have answer in error message ;)
if @ find code:
url:http://localhost:8982/solr/update?wt=ruby>
which means need start solr server. may start simple rails_env=your_env rake sunspot:solr:run
. consider adding begin... rescue
block around @user.save
outputting message rather letting whole app crash.
if you're interested why error without explicit call solr - solr adds callback save
method, indexes every new (or updated) record means won't have (theoretically) reindex scratch after adding new data.
Comments
Post a Comment