【问题标题】:Heroku Rails Setup "The page you were looking for doesn't exist."Heroku Rails 设置“您要查找的页面不存在。”
【发布时间】:2014-02-25 21:21:55
【问题描述】:

我正在关注this Rails tutorial。当我在本地运行 rails server 时,我可以看到“Welcome Aboard”页面。但是,在部署到 Heroku 时,它显示“您要查找的页面不存在”。我四处寻找,但找不到任何可以解决我的问题的东西。以下是我的步骤:

rails new first_app  

对 Gemfile 进行此更改:

group :production do
    gem 'pg'
end

group :development do 
    gem 'sqlite3' 
end

那么,

bundle update
bundle install
bundle install --without production
rake assets:precompile

git init
git add .
git commit -m "initial commit"

heroku login
heroku create
git push heroku master
heroku open

此时它会打开 heroku 应用程序的地址并给出“不存在”错误。检查“heroku 日志”时,它显示我访问的 status=404:

【问题讨论】:

  • 应用部署成功了吗?
  • @archie 它说shrouded-brook-5034.herokuapp.com 已部署到 Heroku。虽然有一些警告。例如,“包含 rails_12factor geme 以启用所有平台功能”、“您尚未在 Gemfile 中声明 Ruby 版本”、“删除 Gemfile.lock,因为它是在 Windows 上生成的”。
  • 我在 group :production 中加入了 gem 'rails_12factor' 并进行了包更新/安装并再次推送到 Heroku。它没有影响任何东西,但警告消失了。
  • 您的rake routes 输出是什么样的?你在某个地方有root to: 吗?
  • 如果您没有定义任何路线,则会显示默认的“欢迎登机”页面。我不确定 Heroku 是否有相同的行为。

标签: ruby-on-rails heroku


【解决方案1】:

从 Rails 4 开始,“Welcome Aboard”页面不再是位于 public 目录中的静态页面,而是位于 Rails 框架本身的烟雾页面。这个页面只会在 development 模式下显示,所以当你部署到 Heroku 并在production 模式下运行时,你不会得到一个自动启动页面。您需要添加 root 路由,否则您将收到您所看到的错误。

见:Where is the default "Welcome Aboard" page located in my app?

【讨论】:

  • 是的,在上面的@user2062950 评论之后,我开始怀疑这一点。感谢您的澄清。
  • 我已经有一个根路由,但我仍然遇到这个问题,但只是在生产中。编辑:这是因为我已经验证了一个用户,然后在注销之前将其从我的数据库中删除。
猜你喜欢
  • 2014-01-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-09-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多