【发布时间】:2016-05-18 02:55:19
【问题描述】:
我有一个 Rails 应用程序在开发中完美运行并经过良好测试。当部署在 heroku 上时,没有报告任何问题,但该应用程序无论如何都无法运行。在浏览器中打开它只会提供:
很抱歉,出了点问题。 如果您是应用程序所有者,请查看日志以获取更多信息。”
在日志中,我看到一个适用于我的变量/表“国家”的 pg 表达式,尽管我不太熟悉其含义:
app[web.1]: pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
app[web.1]: FROM pg_attribute a LEFT JOIN pg_attrdef d
app[web.1]: WHERE a.attrelid = '"countries"'::regclass
app[web.1]: AND a.attnum > 0 AND NOT a.attisdropped
app[web.1]: ORDER BY a.attnum
app[web.1]: app/controllers/application_controller.rb:15:in `default_or_selected_country'
app[web.1]:
heroku[router]: at=info method=GET path="/" host=evening-refuge-96756.herokuapp.com request_id=a240125e-4115-40d4-bfb0-ade1b8c909d6 fwd="178.165.130.180" dyno=web.1 connect=1ms service=204ms status=500 bytes=1714
我看到涉及到我的方法“default_or_selected_country”。各自的代码在开发和测试模式下都没有问题:
def default_or_selected_country
session[:country_id] ||= Country.find_by(abbreviation: "AT").id
@default_or_selected_country = Country.find(session[:country_id]).name
end
在我写这篇文章时,记录了更多类似的 pg 表达式,总是包含“国家”表,并且指向与上面相同的方法。
我的问题在哪里,我该如何解决?谢谢!
【问题讨论】:
-
1.如果你没有在 Heroku 上运行迁移 2. 重启服务器。
-
您确定在国家/地区表中有数据吗?
-
谢谢Sebin,就是这样!
标签: ruby-on-rails ruby postgresql heroku