如何解决 heroku/rails 中的错误 500?
How to solve an error 500 in heroku/rails?
我的应用程序在本地主机上运行良好,但它 return 错误 500:当我在 Heroku 中 运行 时出现内部服务器错误。它说,"We're sorry, but something went wrong. If you are the application owner check the logs for more information."
我的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
它将 return 错误 500
heroku run rake db:migrate
已经完成了,
找到答案了!
我刚刚在 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
中起作用。所以当 运行 this app in localhost
时,上面的代码在 LIKE
子句之前应该没有 i
但是当 运行 this in heroku
时,应该使用 ILIKE
而不是简单的 LIKE
因为当仅在 heroku
中使用 LIKE
子句时,它将区分大小写...
顺便说一下,id
已被删除。
我的应用程序在本地主机上运行良好,但它 return 错误 500:当我在 Heroku 中 运行 时出现内部服务器错误。它说,"We're sorry, but something went wrong. If you are the application owner check the logs for more information."
我的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 它将 return 错误 500
heroku run rake db:migrate
已经完成了,
找到答案了!
我刚刚在 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
中起作用。所以当 运行 this app in localhost
时,上面的代码在 LIKE
子句之前应该没有 i
但是当 运行 this in heroku
时,应该使用 ILIKE
而不是简单的 LIKE
因为当仅在 heroku
中使用 LIKE
子句时,它将区分大小写...
顺便说一下,id
已被删除。