开发者

App pushed to heroku still shows standard index page

开发者 https://www.devze.com 2023-03-12 19:30 出处:网络
I went through the steps to install git and the he开发者_Python百科roku gem and successfully pushed my app to heroku.

I went through the steps to install git and the he开发者_Python百科roku gem and successfully pushed my app to heroku. The problem is, it shows a standard "You're Riding Ruby on Rails" page even though the local app I have has routes set up to root to a certain controller/page. I have also deleted the index.html page from /public.

Any idea why this is happening? I suspect I might needed to switch from development to deployment somehow but still, I deleted the index.html, why is it still showing up on heroku?

EDIT: Going to mysite.heroku/login and other pages I've created works fine for some reason, so nevermind on the deployment thing.


When you're using git and delete a file, that file is not automatically removed from the git repo. So when you git push heroku the file still exists and gets pushed to Heroku.

You can tell if this is the case with git status, which will show something like:

# 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

In order to remove the file, you need to use git rm. In this case you need to do something like:

git rm public/index.html
git commit -m "Removed public/index.html"

which will remove the file from the current branch.

Now when you do

git push heroku

the file won't be included, and so you'll be routed to the controller as specified in routes.rb.


I always use git commit -am "message". That prevented the above problem (which would have definitely happened), and I don't know of any reason not to use -am.

EDIT: Also, be sure to use git add . when you have new files to add.

So, my process is:

git status (to see what has changed)
git add . (if there are new files I want to add to repository)
git commit -am "This is the comment"
git push (to github)
git push heroku (--app app-name if there is more than one app connected to this repository)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号