推送到heroku的应用程序仍然显示标准索引页面

dsp*_*099 17 ruby git deployment ruby-on-rails heroku

我完成了安装git和heroku gem的步骤,并成功将我的应用程序推送到了heroku.问题是,它显示了一个标准的"你正在使用Ruby on Rails"页面,即使我所拥有的本地应用程序已将路由设置为root到某个控制器/页面.我还从/ public删除了index.html页面.

知道为什么会这样吗?我怀疑我可能需要以某种方式从开发切换到部署,但仍然,我删除了index.html,为什么它仍然出现在heroku上?

编辑:转到mysite.heroku /登录和我创建的其他页面由于某种原因工作正常,所以没关系部署的事情.

mat*_*att 40

当您使用git并删除文件时,该文件不会自动从git repo中删除.所以当你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
Run Code Online (Sandbox Code Playgroud)

要删除该文件,您需要使用git rm.在这种情况下,您需要执行以下操作:

git rm public/index.html
git commit -m "Removed public/index.html"
Run Code Online (Sandbox Code Playgroud)

这将从当前分支中删除该文件.

现在当你这样做

git push heroku
Run Code Online (Sandbox Code Playgroud)

该文件不会被包含在内,因此您将被路由到routes.rb中指定的控制器.

  • 你也可以只做`git commit -am"message"`来处理已删除的文件. (4认同)