Rails 2.3.4 Geokit error?

324 views Asked by At

I have a rails application. Rails version is 2.3.4 and ruby version 1.8.7. In that application I used geokit (1.5.0) gem and geokit-rails plugin to find nearest location.

And in my model I have code like this,

class Notary < ActiveRecord::Base

acts_as_mappable

end

And in my controller have code like this,

class Client::OrdersController < ApplicationController

    def find_notary
    @order = Order.find(params[:id])
    @miles = 10
    unless params[:notary_search]
      @notaries = Notary.find(:all, :origin => @order.signing_location_zip_code, :within => @miles, :conditions => "on_vacation IS NOT true",:order=>"distance asc" )
    else
    some code
    end
end

end

I am getting error in that line

@notaries = Notary.find(:all, :origin => @order.signing_location_zip_code, :within => @miles, :conditions => "on_vacation IS NOT true",:order=>"distance asc") like this,

Geokit::Geocoders::GeocodeError in Client/ordersController#find_notary

Geokit::Geocoders::GeocodeError

RAILS_ROOT: /home/user/svnnew_app/trunk/app

Application Trace | Framework Trace | Full Trace

/home/user/.rvm/gems/ruby-1.8.7-p371@app/gems/geokit-1.5.0/lib/geokit/mappable.rb:282:in `normalize'

/home/user/svnnew_app/trunk/app/vendor/plugins/geokit-rails/lib/geokit-rails/acts_as_mappable.rb:347:in `normalize_point_to_lat_lng'

/home/user/svnnew_app/trunk/app/vendor/plugins/geokit-rails/lib/geokit-rails/acts_as_mappable.rb:306:in `extract_origin_from_options'

/home/user/svnnew_app/trunk/app/vendor/plugins/geokit-rails/lib/geokit-rails/acts_as_mappable.rb:203:in `prepare_for_find_or_count'

/home/user/svnnew_app/trunk/app/vendor/plugins/geokit-rails/lib/geokit-rails/acts_as_mappable.rb:108:in `find'

/home/user/svnnew_app/trunk/app/app/controllers/client/orders_controller.rb:331:in `find_notary'

Request

Parameters:

{"id"=>"1198"}

Show session dump Response

Headers:

{"Cache-Control"=>"no-cache", "Content-Type"=>""}

How to resolve this error? Please help me out..

1

There are 1 answers

0
Michael Noack On

I maintain geokit. I had a look at the source code and that line happens when the response back from the API isn't numeric, e.g. a string but not in the format '99.99, 88.88', so would happen if the geocoding API returned 'NA' or something for example.

And I know StackOverflow says "avoid" the following (clarification, opinion, etc.), but here it is:

I can't help further without you doing a few things:

1) If you could update to the latest geokit (gem: 1.7.1 or the latest github master)

2) Do some debugging, e.g. Open "/home/user/.rvm/gems/ruby-1.8.7-p371@app/gems/geokit-1.5.0/lib/geokit/mappable.rb" (line 282) and least "puts" the string that is causing the error along with any other relevant local variables.

Using gems like pry/pry-debugger are a must for any ruby developer to debugging such issues.

3) Update other software where possible (even upgrade to latest ruby 1.8.7 and rails 2.x) You're ruby (1.8.7) and rails (2.x) both are quite old and contain various security issues which should be of some concern. I do my best to keep geokit/geokit-rails working with ruby 1.8.7, but even rails 2 compatibility was dropped in geokit-rails, although I'm happy to help because likely you issue is a problem in geokit-rails with supported rails versions.