Pushing to Heroku with Rails/ruby - ruby-on-rails

I am trying to push to Heroku. I have postgres and have set the buildpacks for Heroku. However I believe it is my file structure that is causing the error.
Main-File -> ProjectName -> RubyProj ->(this is where all the ruby controllers gem stuff is)
Main-File is my git repo and I am trying to push just the RubyProj file to heroku Is there a good way to do this without doing another git init on the RubyProj file?

Actually, it is possible to push only your RubyProj file to heroku, but I don't understand which type of error are you encountering. Try to switch to the appropriate git branch and push the project from the terminal.
cd ~/ProjectName/RubyProj
git checkout master
git commit -m
heroku create
git push heroku master
Also check all the gems and correct bundle installation.
Maybe this book will help you. https://www.railstutorial.org/book/beginning#sec-deploying
Good luck, hope I helped you!

Related

Can't find URL for Heroku repository

I've been following https://github.com/opentok/learning-opentok-ios/tree/basics.step-7 to try and get a video app to work on iOS using the OpenTok SDK.
I've already published an app called dongu using https://dashboard.heroku.com/new?template=https%3A%2F%2Fgithub.com%2Fopentok%2Flearning-opentok-php&button-url=https%3A%2F%2Fgithub.com%2Fopentok%2Flearning-opentok-php. I thought the git URL was git#heroku.com:dongu.git, however it doesn't work.
Error log:
News-MacBook-Pro:Dongu michaelnares$ git remote add heroku git#heroku.com:dongu.git
News-MacBook-Pro:Dongu michaelnares$ git add --all
News-MacBook-Pro:Dongu michaelnares$ git push heroku master
error: src refspec master does not match any.
error: failed to push some refs to 'git#heroku.com:dongu.git'
News-MacBook-Pro:Dongu michaelnares$ git heroku git:remote -a dongu
git: 'heroku' is not a git command. See 'git --help'.
Did you mean this?
checkout
All I want to do is add a simple HTML file to my Heroku app, however I can't find the URL to push to master from. Is there any way of finding it out?
Try
heroku git:remote -a dongu
then
git push heroku master
It might not be a git repo yet.
Run git init first.
Simply following the instructions in https://dashboard.heroku.com/apps/dongu/deploy/heroku-git did the trick, without me needing to know the remote URL, hopefully that's useful for anyone else having this problem.

Could not read from remote repository when pushing to Heroku (Rails Tutorial 5)

I pushed my chapter 5 version of Sample_App to git, and then when I 'git push heroku' I get:
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
! No such app as sample_app.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I have read through some of the similar stackoverflow questions, and so I know to look at the 'git remote -v':
heroku git#heroku.com:sample_app.git (fetch)
heroku git#heroku.com:sample_app.git (push)
origin git#github.com:jeffbenner/sample_app.git (fetch)
origin git#github.com:jeffbenner/sample_app.git (push)
I have tried removing heroku and re-pushing - I get the same error message.
I looked at 'git config -l':
user.name=jeffbenner
user.email=xxxxx#gmail.com
alias.co=checkout
push.defaults=simple
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=false
remote.origin.url=git#github.com:jeffbenner/sample_app.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
remote.heroku.url=git#heroku.com:sample_app.git
remote.heroku.fetch=+refs/heads/*:refs/remotes/heroku/*
I cannot figure out why I cannot push to Heroku. I have re-logged into both my Github and Heroku accounts through the CLI. Any direction would be much appreciated.
I just came across the same problem. I did the following:
cd .git
vim config
removed all lines referencing Heroku
cd ..
heroku create
git push heroku master
... And voila, it worked.
Hoped this helps.
Did you try to specify the branch that you are pushing. Try git push heroku master. You can read about the warning in the docs. Let me know if it worked
Edit
I would just start over all together and create a new Heroku address. Follow these steps in order
First in your Gemfile create these groups
group :development do
gem 'sqlite3'
end
group :production do
gem 'pg'
end
Important, make sure you are in the root of your project and make sure you run bundle install like this
bundle install --without production
now git add . then git commit -m 'your commit message'
now run heroku login from the command line
now run heroku create
then git push heroku master
finally heroku open will open your app in your browser
If all of this doesn't work then move the app into a new directoy and start all over by first git init, git add . and git commit -m 'first commit in new location' and follow the steps above starting with heroku login
Note that heroku and github both use git but are independent entities. If you can push your code to github and you see it on github, then you should be able to push your code to heroku with no problem. If not you may be doing something wrong with git locally on your computer.
I had no idea why, but stopping running foreman in my local machine allowed a push to heroku master... Could be coincidence :|

How to use a heroku app that already exists

please help me,
when I want to upload an rails app to heroku I do this sequence and works creating a new project on heroku
git init
git add .
git commit -m "init"
heroku create
git push heroku master
and then I get a new url like http://-somethingdiferent-.herokuapp.com each time that I need to deploy an project
I dont know how to use that project later without creating other new heroku project
I was thinking to use something like pull of git, but I dont know how is the pull on heroku, maybe -git pull heroku master? but in that case, how can I pull the same project?
please I will like if you know the sequence or any tutorial?
thanks
Try to create an app first
# run this command from the app folder to create a new app
$ heroku open --app the-app-name
# Add it to the remote
$ heroku git:remote -a the-app-name
# push app to heroku
$ git push heroku master
the-app-name shall be replaced by the application name.
one can find more useful stuff here.

rails app in development doesn't show up on heroku

Im developing a rails app. Following this tutorial here:
Tutorial
I finished a part and wanted to push all the changes up to heroku and view them there. I can view the site on my local machine. On heroku all I see is this:
I typed in the following commands after I made my changes, saw the site was working on my local computer.
$ git add .
$ git commit -m "Finish layout and routes"
$ git checkout master
$ git push
$ git push heroku
$ heroku open
I even looked at the heroku logs but couldn't make sense of whats going wrong! There is no content in my database, its empty. I just have views setup.
Why did you checkout to master? Are you working on another branch?
If that is the case, you will need to merge your changes to master before pushing your code (supposing you are on master which is already the case after the checkout):
git merge other-branch
Also don't forget to migrate your database on heroku.
heroku rake db:migrate
EDIT
To find out your current branch, type:
git branch
It will mark the current branch with a '*'.
If you have removed the public/index.html file, you'll have to do git rm public/index.html as well, then commit and push to Heroku. If you delete a file locally, git won't pick up on that without doing the git rm, and Heroku's knowledge of your app is 100% through Git.
I had a similarly strange (but unrelated) problem when I had an app that was storing uploaded files on Heroku. Every time I'd do a push they'd all go away. It confused me greatly until I realized that Heroku essentially wipes every time you do a push, and anything that isn't in git isn't kept. A good reason to use S3 or similar for uploaded file storage.

cloned project from github. heroku does not work

I cloned a project from github over to my desktop. I used to work on it form my laptop.
However, on laptop heroku does not seem to work for this app eventhough i have it installed.
First problem:
heroku open
>No app specified.
>Run this command from app folder or set it adding --app <app name>
I did not have to specify the --app on my laptop. Because I guess I did command heroku create initially on the lapop.
Second Probelm:
git push heroku master
gives errors
fatal: 'heroku' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
and heroku list
says
! This version of the heroku gem has been deprecated.
! Please update it by running: gem update heroku
First do:
git remote add heroku git#heroku.com:{my-project-name}.git
Where you replace {my-project-name} with the name of the Heroku application as it appears in your Heroku account. For example, if your Heroku account says you have an application named flowing-water-397, then the line would be:
git remote add heroku git#heroku.com:flowing-water-397.git
Then Git and the Heroku gem will know that this Git repo is connected to a Heroku.com application. Then you can do things such as:
git push heroku master
heroku open
Finally, learn a little bit more about Git Remotes.
In addition to the git remote add ... that #Justice mentioned, I also needed to run
git config heroku.remote heroku
(solution found here)
I believe I get the error No app specified. Run this command from an app folder or specify which app to use with --app when I run any ambiguous heroku commands. Example:
heroku logs
It's ambiguous because I have multiple remote repositories specified in my project's .git/config file. The solution for me is simply to specify the remote repository. Example:
heroku logs --remote staging
In the above line --remote staging corresponds to the following in my project's .git/config file:
[remote "staging"]
url = git#heroku.accountname:foo-bar-1234.git
fetch = +refs/heads/*:refs/remotes/staging/*
I hope this helps you.. if not, then perhaps it may help someone else!
When I had this issue it was because I created more than one remote app on heroku.
To remove an existing remote app from heroku use:
git remote rm heroku
then go back and use heroku create to start the process over using the correct app name heroku gives you.
Solution found here:
solution

Resources