路由在开发环境下工作,推送到 Heroku 时出现 ActionController::RoutingError

发布于 2024-10-18 08:34:17 字数 1472 浏览 2 评论 0原文

我希望这里有人可以帮助我解决这个问题。我正在我的开发环境中创建一个静态网页,因此我的路由文件中有一行:

TeaserSite::Application.routes.draw do
  root               :to => 'pages#home'
end

在我的开发环境中,此单页面显示正确。当我将此代码推送到 heroku 时,我在该页面收到 404 错误。当我访问 root url 时,heroku 的日志输出:

2011-02-20T23:07:36-08:00 app[web.1]: Started GET "/" for 76.28.89.32 at Sun Feb 20 23:07:36 -0800 2011
2011-02-20T23:07:36-08:00 app[web.1]: 
2011-02-20T23:07:36-08:00 app[web.1]: 
2011-02-20T23:07:36-08:00 app[web.1]: ActionController::RoutingError (uninitialized constant PagesController):

我的开发环境中的 Rails 服务器输出:

Started GET "/" for 127.0.0.1 at 2011-02-21 02:16:58 -0500
  Processing by PagesController#home as HTML
Rendered pages/home.html.erb within layouts/application (13.3ms)
Completed 200 OK in 85ms (Views: 83.6ms | ActiveRecord: 0.0ms)

我检查了以下 StackOverflow 问题以了解一些优先级,但没有任何帮助。我没有正确的 aws gem,将 config.serve_static_assets 更改为 true 没有帮助,我使用了“git add”。在推送到 heroku 之前执行命令。有人知道可能是什么问题吗?对于初学者来说,有什么方法可以确认 PagesController 文件实际上已推送到 Heroku(除了调用 git push heroku 返回“所有内容都是最新的”之外)?

Rails - 部署中的路由失败 Rails 生产静态文件路由错误 Heroku:部署 Rails 应用程序遇到问题

I hope someone here can help me with this issue. I am creating a static webpage on my dev environment, so my routing file has one line in it:

TeaserSite::Application.routes.draw do
  root               :to => 'pages#home'
end

On my dev environment, this single page shows up correctly. When I pushed this code to heroku, I get a 404 error at that page. Log output for heroku when I visit the root url:

2011-02-20T23:07:36-08:00 app[web.1]: Started GET "/" for 76.28.89.32 at Sun Feb 20 23:07:36 -0800 2011
2011-02-20T23:07:36-08:00 app[web.1]: 
2011-02-20T23:07:36-08:00 app[web.1]: 
2011-02-20T23:07:36-08:00 app[web.1]: ActionController::RoutingError (uninitialized constant PagesController):

Rails server output on my dev environment:

Started GET "/" for 127.0.0.1 at 2011-02-21 02:16:58 -0500
  Processing by PagesController#home as HTML
Rendered pages/home.html.erb within layouts/application (13.3ms)
Completed 200 OK in 85ms (Views: 83.6ms | ActiveRecord: 0.0ms)

I checked the following StackOverflow questions for some precedence with this but nothing has helped. I don't have the right-aws gem, changing config.serve_static_assets to true did not help, and I used the "git add ." command before pushing to heroku. Anybody know what the problem could be? For starters, is there any way I can confirm that the PagesController file was actually pushed to Heroku (aside from that calling git push heroku returns "everything up to date")?

Rails - Failing Routes in deployment
Rails production static files routing error
Heroku: Deploying rails application troubles

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

爱殇璃 2024-10-25 08:34:17

您实际上有一个名为 PagesController 的控制器吗?您是否确保文件名和标题中的拼写正确。

Do you actually have a controller called PagesController. Did you make sure it is spelled correctly as the filename and in the header.

傲性难收 2024-10-25 08:34:17

我遇到了完全相同的问题 - 在我的开发环境中一切正常,但我在 heroku 上遇到了该错误。我通过删除和更改大部分迁移文件对模型进行了一些重大更改,我怀疑 RubyMine 感到困惑并且没有正确推送所有内容。所以我在控制台中手动执行了以下操作:

git add .
git commit -m "Your comment here"
git push heroku master
heroku rake db:reset # this will force migrate on everything
heroku rake db:migrate # not necessary really, but just to make sure ...
heroku restart # the important bit

问题就消失了。

I had exactly the same problem - everything was working fine on my development environment, but I got that error on heroku. I made some major changes in my models by deleting and changing most of the migrations files, and I suspect, RubyMine got confused and didn't pushed everything correctly. So I did the following manually in the console:

git add .
git commit -m "Your comment here"
git push heroku master
heroku rake db:reset # this will force migrate on everything
heroku rake db:migrate # not necessary really, but just to make sure ...
heroku restart # the important bit

And the problem disappeared.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文