【发布时间】:2012-01-28 21:13:57
【问题描述】:
我正在使用 rails3-jquery-autocomplete gem 在我的 rails 3 应用程序的表单中自动完成字段(产品)。用户可以键入产品名称或产品代码,它们都是产品表中的字符串列。 在本地一切正常,但在 heroku 上,ajax 请求因标准 500 heroku 错误而崩溃:
We're sorry, but something went wrong (500)
我认为这可能是 postgre / sql 问题 - 我在本地使用 mysql 进行开发,但 heroku 在 postgre sql 数据库上运行,并且我在通过 ajax 自动完成请求调用的函数中执行以下查询:
def get_autocomplete_items(parameters)
items = Product.select("DISTINCT CONCAT_WS(' ', product_code, title, id) AS full_name, product_code, title, id").where(["CONCAT_WS(' ', product_code, title) LIKE ?", "%#{parameters[:term]}%"])
end
在本地,这将返回一个 json 格式的数组,包括所有匹配的 produc_ids 和名称:
[{"id":"9","label":"xt-pnt-dress_45 - Catherine Malandrino","value":"xt-pnt-dress_45 - Catherine Malandrino"}, ... ]
如果有人知道如何更改符合 heroku 或任何其他想法的查询,我将不胜感激。谢谢。
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 postgresql autocomplete heroku