2015-03-31 67 views
0

我的应用程序在localhost中工作正常,但它在Heroku中运行时返回错误500:内部服务器错误。它说,“我们很抱歉,但出了问题,如果你是应用程序所有者,请查看日志以获取更多信息。”如何解决heroku/rails中的错误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 

已经完成,但仍,

+0

看到heroku日志,'heroku插件:升级日志记录:展开',然后'英雄日志 - 尾巴' – Sontya 2015-03-31 05:51:09

+0

@Sontya它说,找不到附加计划。 – MAC 2015-03-31 05:54:10

+0

键入这个并查看错误'heroku logs -n 1000' – Sontya 2015-03-31 05:55:57

回答

0

找到了答案!

我只是在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因为只有在heroku使用LIKE条款时,这将是区分大小写..

并且顺便说一句,id被删除。

+0

请将此代码移至模型 – duykhoa 2015-03-31 09:44:58

相关问题