ruby - undefined method `to_sym' on nil:NilClass on rubysl/net/http/http.rb caused by Rails Geocoder -


so i've working on website on ruby on rails uses geocoder gem.

here implementation:

def user < activerecord::base         before_save :geocode     geocoded_by :address |usr, geocode_results|     if geo = geocode_results.first        usr.latitude  = geo.latitude        usr.longitude = geo.longitude        usr.geocode_address = geo.address     else       usr.latitude  = nil       usr.longitude = nil       usr.geocode_address = nil     end end 

and on production works... in 2-3 days i'll error saying undefined method to_sym on nil:nilclass. on controller action calls @user.save

i investigated further, , here stack trace:

stacktrace (most recent call first):    kernel/delta/kernel.rb:78:in `to_sym (method_missing)' rubysl/net/http/http.rb:576:in `start'    key = $1.to_sym kernel/common/enumerable.rb:217:in `grep' kernel/bootstrap/array.rb:76:in `each' kernel/common/enumerable.rb:213:in `grep' rubysl/net/http/http.rb:575:in `start'     http.methods.grep(/\a(\w+)=\z/) |meth| geocoder/lookups/base.rb:268:in `make_api_request'     http_client.start(uri.host, uri.port, use_ssl: use_ssl?) |client| rubysl/timeout/timeout.rb:149:in `timeout'     yield sec rubysl/timeout/timeout.rb:168:in `timeout'      timeout.timeout(n, e, &block) geocoder/lookups/base.rb:266:in `make_api_request'     timeout(configuration.timeout) geocoder/lookups/base.rb:218:in `fetch_raw_data'     response = make_api_request(query) geocoder/lookups/base.rb:169:in `fetch_data'     parse_raw_data fetch_raw_data(query) geocoder/lookups/google.rb:28:in `results'     return [] unless doc = fetch_data(query) geocoder/lookups/base.rb:47:in `search'     results(query).map{ |r| geocoder/query.rb:11:in `execute'     lookup.search(text, options) geocoder.rb:21:in `search'     query.blank? ? [] : query.execute geocoder/stores/base.rb:111:in `do_lookup'      results = geocoder.search(query, query_options) geocoder/stores/active_record.rb:259:in `geocode'     do_lookup(false) |o,rs|   active_support/callbacks.rb:424:in `make_lambda'     lambda { |target, _, &blk| target.send filter, &blk } 

it turns out this culprit on to_sym nil:nilclass error - seems grep isn't finding anything?

the net:http being called rails geocoder here.

i suspect rbx-2.2.1 issue, i'm gonna try switching ruby-2.2.1 , see if happens in next couple days. has ever happened anyone?

edit: if restart rails server thread problem goes away, come in ~1-2 days

edit: user_controller caused issue

respond_to |format| #line 169     @id = @user.id     @user.update(user_params) #line 171     if params[:user][:redirect_to_index].present? or @user.chef?         format.html { redirect_to root_path }         format.json { render :show, status: :ok, location: @user }     else         format.html { redirect_to @user }         format.json { render :show, status: :ok, location: @user }     end end 

i fixed issue switching rbx-2.2.1 ruby-2.2.1. seems caused bug between geocoder , rbx-2.2.1 (i think).


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -