路由在开发环境下工作,推送到 Heroku 时出现 ActionController::RoutingError
我希望这里有人可以帮助我解决这个问题。我正在我的开发环境中创建一个静态网页,因此我的路由文件中有一行:
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 返回“所有内容都是最新的”之外)?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您实际上有一个名为
PagesController
的控制器吗?您是否确保文件名和标题中的拼写正确。Do you actually have a controller called
PagesController
. Did you make sure it is spelled correctly as the filename and in the header.我遇到了完全相同的问题 - 在我的开发环境中一切正常,但我在 heroku 上遇到了该错误。我通过删除和更改大部分迁移文件对模型进行了一些重大更改,我怀疑 RubyMine 感到困惑并且没有正确推送所有内容。所以我在控制台中手动执行了以下操作:
问题就消失了。
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:
And the problem disappeared.