현재이 하나의 ActiveRecord 쿼리에서 오류가 계속 발생하는 Heroku 앱이 있습니다.heroku activerecord 쿼리 오류
if category == "-1"
where('category_id IS null')
else
where('category_id IS ?', category)
end
'CATEGORY_ID과의 첫 번째 쿼리가 null 작품을 잘하지만 두 번째 쿼리는 오류 발생 :
이2012-08-16T18:58:03+00:00 app[web.1]:
2012-08-16T18:58:03+00:00 app[web.1]:
2012-08-16T18:58:03+00:00 app[web.1]: Started GET "/items?cpath=4" for 204.154.121.30 at 2012-08-16 18:58:03 +0000
2012-08-16T18:58:08+00:00 app[web.1]:
2012-08-16T18:58:08+00:00 app[web.1]: ActiveRecord::StatementInvalid (PGError: ERROR: syntax error at or near "4"
2012-08-16T18:58:08+00:00 app[web.1]: LINE 1: SELECT COUNT(*) FROM "items" WHERE (category_id IS 4)
2012-08-16T18:58:08+00:00 app[web.1]: ^
2012-08-16T18:58:08+00:00 app[web.1]: app/controllers/items_controller.rb:30:in `index'
2012-08-16T18:58:08+00:00 app[web.1]: : SELECT COUNT(*) FROM "items" WHERE (category_id IS 4)):
2012-08-16T18:58:08+00:00 app[web.1]:
2012-08-16T18:58:08+00:00 app[web.1]:
2012-08-16T18:58:08+00:00 app[web.1]: cache: [GET /items?cpath=4] miss
2012-08-16T18:58:08+00:00 app[web.1]: Processing by ItemsController#index as HTML
2012-08-16T18:58:08+00:00 app[web.1]: Parameters: {"cpath"=>"4"}
2012-08-16T18:58:08+00:00 app[web.1]: Completed 500 Internal Server Error in 3ms
2012-08-16T18:58:08+00:00 heroku[router]: GET yisifahan.herokuapp.com/items?cpath=4 dyno=web.1 queue=0 wait=0ms service=
5026ms status=500 bytes=728
2012-08-16T18:58:08+00:00 heroku[web.1]: Error R12 (Exit timeout) -> At least one process failed to exit within 10 seconds of SIGTERM
2012-08-16T18:58:08+00:00 heroku[web.1]: Stopping remaining processes with SIGKILL
2012-08-16T18:58:09+00:00 heroku[web.1]: Process exited with status 137
사람이이 문제를 해결하는 방법을 알고 있나요을? 감사.
그럼 null 문과 마찬가지로 'where (category : nil)' – Iamvery
정말 도움이되었습니다. – pandapirate