gpt4 book ai didi

ruby-on-rails - 为什么 Postgresql 会像这样使用 Geokit 失败?

转载 作者:行者123 更新时间:2023-11-29 12:31:51 24 4
gpt4 key购买 nike

我刚刚开始使用 geokit 和 Rails 来开发我的应用程序建筑。我已经对我的记录进行了地理编码,但是当我去的时候进入控制台看看我能用它做什么然后它就爆炸了使用以下内容:用户是一个用户对象,其中包含来 self 的经纬度和经纬度数据库

>> Restaurant.find(:all, :origin => user) 

Restaurant Load (0.0ms) PGError: ERROR: operator does not exist:
numeric - character varying
LINE 1: ...*, SQRT(POW(111.1819*(-33.872517-restauran...
^
HINT: No operator matches the given name and argument type(s). You
might need to add explicit type casts.
: SELECT *, SQRT(POW(111.1819*(-33.872517-restaurants.lat),2)+
POW(76.7136337302943*(151.205536-restaurants.lng),2))
AS distance FROM "restaurants"
ActiveRecord::StatementInvalid: PGError: ERROR: operator does not
exist: numeric - character varying
LINE 1: ...*, SQRT(POW(111.1819*(-33.872517-
restauran...
^
HINT: No operator matches the given name and argument type(s). You
might need to add explicit type casts.
: SELECT *, SQRT(POW(111.1819*(-33.872517-
restaurants.lat),2)+
POW(76.7136337302943*(151.205536-restaurants.lng),
2))
AS distance FROM "restaurants"
from /Users/chris/projects/mine/lunchdecider/vendor/rails/
activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:
212:in `log'
from /Users/chris/projects/mine/lunchdecider/vendor/rails/
activerecord/lib/active_record/connection_adapters/
postgresql_adapter.rb:538:in `execute'
from /Users/chris/projects/mine/lunchdecider/vendor/rails/
activerecord/lib/active_record/connection_adapters/
postgresql_adapter.rb:1019:in `select_raw'
from /Users/chris/projects/mine/lunchdecider/vendor/rails/
activerecord/lib/active_record/connection_adapters/
postgresql_adapter.rb:1006:in `select'
from /Users/chris/projects/mine/lunchdecider/vendor/rails/
activerecord/lib/active_record/connection_adapters/abstract/
database_statements.rb:7:in `select_all_without_query_cache'
from /Users/chris/projects/mine/lunchdecider/vendor/rails/
activerecord/lib/active_record/connection_adapters/abstract/
query_cache.rb:62:in `select_all'
from /Users/chris/projects/mine/lunchdecider/vendor/rails/
activerecord/lib/active_record/base.rb:661:in `find_by_sql'
from /Users/chris/projects/mine/lunchdecider/vendor/rails/
activerecord/lib/active_record/base.rb:1548:in `find_every'
from /Users/chris/projects/mine/lunchdecider/vendor/rails/
activerecord/lib/active_record/base.rb:615:in `find'
from /Users/chris/projects/mine/lunchdecider/vendor/plugins/geokit-
rails/lib/geokit-rails/acts_as_mappable.rb:138:in `find'
from (irb):10

有什么办法可以解决这个问题吗?不幸的是谷歌并不多在我尝试搜索我的错误消息时提供帮助 ...

最佳答案

在您的迁移中,您可能将 restaurants.lat 和 restaurants.lng 创建为字符串(字符可变),而它们应该是 float 。 Postgres 不会为你投那个。更改列类型,您应该没问题。

关于ruby-on-rails - 为什么 Postgresql 会像这样使用 Geokit 失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1370461/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com