【问题标题】:How to solve an error 500 in heroku/rails?如何解决heroku/rails中的错误500?
【发布时间】:2015-03-31 05:45:57
【问题描述】:

我的应用程序在 localhost 中运行良好,但在 Heroku 中运行时返回错误 500:内部服务器错误。它说:“我们很抱歉,但出了点问题。如果您是应用程序所有者,请查看日志以获取更多信息。”

我的 routes.rb 下有这个

  get 'employees/showemployees'
  resources :employees

这个,在我的控制之下

def showemployees
str = params[:str]
render json: @employee = Employee.where('fname LIKE ? OR lname LIKE ? OR mname LIKE ? OR username LIKE ? or id LIKE ?',
       "%#{str}%","%#{str}%","%#{str}%", "%#{str}%", "%#{str}%")

结束

当我输入http://localhost:3000/employees/showemployees?str=samplename 它显示记录的 json 格式但是当我输入 https://dtitdtr.herokuapp.com/employees/showemployees?str=samplename 它将返回错误 500

heroku run rake db:migrate

已经完成了,还没有,

【问题讨论】:

  • 查看 heroku 日志,heroku addons:upgrade logging:expanded 然后heroku logs --tail
  • @Sontya 它说,未找到附加计划。
  • 输入这个并查看错误heroku logs -n 1000
  • @Sontya 它说,没有运算符匹配给定的名称和参数类型。您可能需要添加显式类型转换。
  • 尝试删除,id 比较,然后查找 fname、lname、mname 和用户名

标签: ruby-on-rails ruby heroku internal-server-error


【解决方案1】:

找到答案了!

我刚刚在LIKE 子句中添加了i,就像ILIKE 这样的代码

render json: @employee = Employee.where('fname ILIKE ? OR lname ILIKE ? OR mname ILIKE ? OR username ILIKE ?',
   "%#{str}%","%#{str}%","%#{str}%", "%#{str}%")

它不适用于localhost,但它适用于heroku。因此,当在localhost 中运行这个应用程序时,上面的代码在LIKE 子句之前应该没有i,但是当在heroku 中运行它时,应该使用ILIKE 而不是简单的LIKE,因为当使用@ 987654333@ 子句仅在heroku 中,它会区分大小写...

顺便说一句,id 已被删除。

【讨论】:

    猜你喜欢
    • 2018-01-09
    • 2018-08-18
    • 1970-01-01
    • 1970-01-01
    • 2020-07-31
    • 2016-08-04
    • 2022-08-17
    • 2020-01-21
    • 1970-01-01
    相关资源
    最近更新 更多