我完成了安装 git 和 heroku gem 的步骤,并成功将我的应用程序推送到 heroku。 问题是,它显示了一个标准的“您正在使用 Ruby on Rails”页面,即使我拥有的本地应用程序已将路由设置为根目录到某个 Controller /页面。我还从/public 中删除了 index.html 页面。
知道为什么会这样吗?我怀疑我可能需要以某种方式从开发切换到部署,但我仍然删除了 index.html,为什么它仍然出现在 heroku 上?
编辑:转到 mysite.heroku/login 和我创建的其他页面出于某种原因工作正常,所以不要介意部署问题。
最佳答案
当您使用 git 并删除文件时,该文件不会自动从 git 存储库中删除。因此,当您 git push heroku
时,文件仍然存在并被推送到 Heroku。
您可以通过 git status
判断是否属于这种情况,它将显示如下内容:
# Changes not staged for commit:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: public/index.html
为了删除文件,您需要使用git rm
。 .在这种情况下,您需要执行以下操作:
git rm public/index.html
git commit -m "Removed public/index.html"
这将从当前分支中删除文件。
当你这样做的时候
git push heroku
该文件不会被包含,因此您将被路由到 routes.rb 中指定的 Controller 。
关于ruby-on-rails - 推送到 heroku 的应用程序仍然显示标准索引页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6351182/