2016-06-23 3 views
1

を変える文字は、私は、クエリを打つ私のコントローラである:Rails 4.1。 HerokuのはActiveRecord :: StatementInvalid(PG :: UndefinedFunction:ERROR:演算子は存在しません:数値 - ここに

def search_by_location 
    @stores = Store.includes(:images).near([params[:latitude], params[:longitude]], 10) 
end 

すべてがローカルマシン上で素晴らしい作品PGで。 。、Herokuの私はエラーを取得する

ここでは、ログです:OPとのコメントを1として

2016-06-23T08:04:56.392549+00:00 heroku[router]: at=info method=POST path="/api/customer/search_by_location?type=daeal&page=1" host=loyelte.herokuapp.com request_id=0364888a-3866-4acd-bea0-17a4bf4eaeee fwd="122.162.251.21" dyno=web.1 connect=0ms service=14ms status=500 bytes=1669 
2016-06-23T08:04:56.362768+00:00 app[web.1]: Started POST "/api/customer/search_by_location?type=daeal&page=1" for 122.162.251.21 at 2016-06-23 08:04:56 +0000 
2016-06-23T08:04:56.365114+00:00 app[web.1]: Processing by Customer::CustomersController#search_by_location as */* 
2016-06-23T08:04:56.365163+00:00 app[web.1]: Parameters: {"latitude"=>"28", "longitude"=>"77", "type"=>"daeal", "page"=>"1", "customer"=>{}} 
2016-06-23T08:04:56.366751+00:00 app[web.1]: Authentication Load (0.8ms) SELECT "authentications".* FROM "authentications" WHERE "authentications"."auth_token" = $1 AND "authentications"."subject_type" = $2 LIMIT 1 [["auth_token", "41360d38bef547ab8e9ae2ce47459c53"], ["subject_type", "Customer"]] 
2016-06-23T08:04:56.368775+00:00 app[web.1]: Customer Load (0.9ms) SELECT "customers".* FROM "customers" WHERE "customers"."id" = $1 LIMIT 1 [["id", 3]] 
2016-06-23T08:04:56.371919+00:00 app[web.1]: Store Load (1.4ms) SELECT stores.*, 3958.755864232 * 2 * ASIN(SQRT(POWER(SIN((28.0 - stores.latitude) * PI()/180/2), 2) + COS(28.0 * PI()/180) * COS(stores.latitude * PI()/180) * POWER(SIN((77.0 - stores.longitude) * PI()/180/2), 2))) AS distance, MOD(CAST((ATAN2(((stores.longitude - 77.0)/57.2957795), ((stores.latitude - 28.0)/57.2957795)) * 57.2957795) + 360 AS decimal), 360) AS bearing FROM "stores" WHERE (stores.latitude BETWEEN 27.85526821688915 AND 28.14473178311085 AND stores.longitude BETWEEN 76.83608111706583 AND 77.16391888293417 AND (3958.755864232 * 2 * ASIN(SQRT(POWER(SIN((28.0 - stores.latitude) * PI()/180/2), 2) + COS(28.0 * PI()/180) * COS(stores.latitude * PI()/180) * POWER(SIN((77.0 - stores.longitude) * PI()/180/2), 2)))) BETWEEN 0.0 AND 10) ORDER BY distance ASC 
2016-06-23T08:04:56.372212+00:00 app[web.1]: Completed 500 Internal Server Error in 7ms (ActiveRecord: 3.1ms) 
2016-06-23T08:04:56.373468+00:00 app[web.1]: 
2016-06-23T08:04:56.373476+00:00 app[web.1]: ActiveRecord::StatementInvalid (PG::UndefinedFunction: ERROR: operator does not exist: numeric - character varying 
2016-06-23T08:04:56.373477+00:00 app[web.1]: LINE 1: ...*, 3958.755864232 * 2 * ASIN(SQRT(POWER(SIN((28.0 - stores.l... 
2016-06-23T08:04:56.373477+00:00 app[web.1]:               ^
2016-06-23T08:04:56.373478+00:00 app[web.1]: HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. 
2016-06-23T08:04:56.373479+00:00 app[web.1]: : SELECT stores.*, 3958.755864232 * 2 * ASIN(SQRT(POWER(SIN((28.0 - stores.latitude) * PI()/180/2), 2) + COS(28.0 * PI()/180) * COS(stores.latitude * PI()/180) * POWER(SIN((77.0 - stores.longitude) * PI()/180/2), 2))) AS distance, MOD(CAST((ATAN2(((stores.longitude - 77.0)/57.2957795), ((stores.latitude - 28.0)/57.2957795)) * 57.2957795) + 360 AS decimal), 360) AS bearing FROM "stores" WHERE (stores.latitude BETWEEN 27.85526821688915 AND 28.14473178311085 AND stores.longitude BETWEEN 76.83608111706583 AND 77.16391888293417 AND (3958.755864232 * 2 * ASIN(SQRT(POWER(SIN((28.0 - stores.latitude) * PI()/180/2), 2) + COS(28.0 * PI()/180) * COS(stores.latitude * PI()/180) * POWER(SIN((77.0 - stores.longitude) * PI()/180/2), 2)))) BETWEEN 0.0 AND 10) ORDER BY distance ASC): 
+0

* geocoder * gemをインストールした後に、Herokuデプロイメントで移行が正常に実行されましたか?あなたの移行で 'stores'テーブルの' latitude'と 'longitude'フィールドが' float'に設定されていることを確認してください。 – Uzbekjon

+0

あなたのすばらしい返答に感謝します。 私が 'latitude'と' longitude'フィールドを** floatに変更したとき**データ型**は私のために働いていました。 – Saurabh

+0

将来のGoogle社員と余分な+25の回答として追加してください。 – Uzbekjon

答えて

1

、彼はgeocoder宝石を使用しているlatitudeおよび0123のテーブルのフィールドを。フィールドはfloatに設定する必要があります。

関連する問題