如何处理Geokit::Geocoders::GeocodeError在rails 3



嗨,我在Ruby on Rails 3中使用Geokit插件,它对我来说很好。但是当我给出原点值时它会抛出Geokit::Geocoders::GeocodeError

下面是我的代码:
@listing = Listing.geo_scope(:origin=>"sdfaasssssssdfdfsdfdfdfdfsdfsdfsdfsdfsdf")
错误:

Geokit::Geocoders::GeocodeError: Geokit::Geocoders::GeocodeError
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/geokit-1.5.0/lib/geokit/mappable.rb:282:in `normalize'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/geokit-rails3-0.1.2/lib/geokit-rails3/acts_as_mappable.rb:229:in `normalize_point_to_lat_lng'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/geokit-rails3-0.1.2/lib/geokit-rails3/acts_as_mappable.rb:189:in `extract_origin_from_options'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/geokit-rails3-0.1.2/lib/geokit-rails3/acts_as_mappable.rb:111:in `geo_scope'
from (irb):3
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands/console.rb:44:in `start'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands/console.rb:8:in `start'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:23:in `<top (required)>'
from D:/ariv/projects/RubyMine/rentstore/script/rails:6:in `require'
from D:/ariv/projects/RubyMine/rentstore/script/rails:6:in `<top (required)>'
from -e:1:in `load'
from -e:1:in `<main>

如何处理这个错误?

谢谢,

L。Arivarasan

我不知道你到底是什么意思,但也许你想要这样的东西

    begin
        @listing = Listing.geo_scope(:origin=>"sdfaasssssssdfdfsdfdfdfdfsdfsdfsdfsdfsdf")
    rescue Geokit::Geocoders::GeocodeError
        # handle the error here :-)
    end

相关内容

  • 没有找到相关文章

最新更新