##heroku PostgreSQLのエラー
Sinatraのアプリをherokuにデプロイしたのですが、PostgreSQLのエラーが出てしまいうまく動きません(開発環境のsqlite3では問題なく動きます)。
テーブル構造は下記です。
SQL
1 Column | Type | Modifiers 2------------+-----------------------------+---------------------------------------------------- 3 id | integer | not null default nextval('posts_id_seq'::regclass) 4 user | text | 5 comment | text | 6 number | integer | default 0 7 URL | text | 8 title | text | 9 eid | integer | 10 icon | text | 11 run | integer | default 0 12 created_at | timestamp without time zone | 13 updated_at | timestamp without time zone | 14Indexes:
コントローラー。get
で受け取った変数(eid)を使ってActiverecordで検索し返したいです。
lang
1#main.rb 2get "/:eid" do 3 eid = params[:eid] 4 eid = eid.to_i 5 $cont = Post.select("user","comment","number","icon").where("run" => 1,"eid" => eid).distinct 6 $head = Post.select("URL", "title").where("run" => 1,"eid" => eid).distinct 7 erb :comments 8end
herokuのログでは、このようなエラー文が出ます。
ActiveRecord::StatementInvalid - PG::UndefinedFunction: ERROR: function count(name, text, integer, text) does not exist LINE 1: SELECT DISTINCT COUNT(DISTINCT user, comment, number, icon) ... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. : SELECT DISTINCT COUNT(DISTINCT user, comment, number, icon) FROM "posts" WHERE "posts"."run" = 1 AND "posts"."eid" = 314804866:
##試したこと
変数を使わないほかのところではエラーが出ないので、変数eidでWHEREするときの型の問題かなと思ったのですが、integer型に対して.to_iで数字にして入れてみましたがうまくいきません。
原因等分かる方いらっしゃいましたらご教示くだされば幸いです。
###追記
ちょっとまだエラーメッセージの解読もよくできていないのですが、エラーメッセージ1行目のfunction count(name, text, integer, text) does not exist
で、なぜかname型(?)になっていて、参照しているテーブルのuserカラム(text型)と食い違っているのが原因でしょうか?

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/02/21 03:45