Deploy Rails app to Heroku without using git? [duplicate] - ruby-on-rails

This question already has answers here:
Upload to heroku without git
(3 answers)
Closed 8 years ago.
I was doing the Ruby on Rails tutorial by Michael Hartl and after finishing all the chapters, I run the app on my local server and it worked.
Whenever I tried pushing it on github, I get message like "nothing to commit, working directory clean".
Now I want to deploy it on heroku. I have tried but it did not work. Is there another way to deploy to heroku without version control ? Or should I just restart my application from zero ?
How should I go about fixing the git problem ?

Yes you can deploy to heroku without using git.
You can use a plugin heroku push. You can find it at https://github.com/ddollar/heroku-push.

There is not another way to deploy to Heroku.
Git is a powerful decentralized revision control system, and is the means for deploying apps to Heroku.
(Emphasis added.)
It's not necessary to restart your application in order to deploy it to Heroku though. You can deploy by initializing a Git repository in your application's directory, "committing" your application in its current state, then "pushing" that commit to Heroku. To begin tracking your application in Git (assuming Git is installed), run the following commands at your command line:
$ cd myapp
$ git init
Initialized empty Git repository in .git/
$ git add .
$ git commit -m "my first commit"
Created initial commit 5df2d09: my first commit
44 files changed, 8393 insertions(+), 0 deletions(-)
create mode 100644 README
create mode 100644 Procfile
create mode 100644 app/controllers/source_file
...
For more information, see Heroku's article, Deploying with Git.

Related

Issue with Git folder placement and Heroku deployment

When I first ran my rails generator it created a folder inside of the folder I wanted to have my repository work from. What I mean by this is my github folder structure looks like this:
https://github.com/milosbunijevac/medRails
the medtools folder has the entire project, but the initial repository was started one level above the medtools folder as the repository above shows.
When I run the following commands:
heroku create
heroku buildpacks:add --index 1 heroku/nodejs
heroku buildpacks:add --index 2 heroku/ruby
and then git push heroku master from the root directory (one level above medtools) I get an error saying that app not compatible with buildpack and that the push was rejected. I'm thinking it has something to do with this strange folder structure. Do you guys and gals have any insights as to how I might fix this issue and get my project to deploy to heroku?
You could locally move everything one level up, and push back to GitHub, done in a bash session:
cd /path/to/repo
git mv medtools/* .
git rm medtools
git add .
git commit -m "move medtools content"
git push
As the OP Milos comments below, you might have to tweak the .gitignore content.

The page you were looking for doesn't exist

I'm trying to learn Rails ( developpment beginner here )
When I try to deploy my first app on Heroku and execute $ heroku open I got
"The page you were looking for doesn't exist.”
In my Heroku control pannel I also have a second link who works, http://secret-refuge-2130.herokuapp.com/, but different from localhost.
Here's my first app https://github.com/Freysh/first_app
As Michael Hartl propose "Unfortunately, the resulting page is an error; as of Rails 4.0, for technical reasons the default Rails page doesn’t work on Heroku. The good news is that the error will go away (in the context of the full sample application) when we add a root route in Section 5.3.2."
You need to work on the Root route of your routes.rb in config folder.
Looks like you haven't pushed your repo to Heroku yet?
Since you're new, let me give you some ideas about how Heroku works, and how you can deploy your app to it...
Heroku
When you use Heroku, you basically get a bare git repo which you can push your application to. This repo will essentially allow you to use the following commands:
> $ git add .
> $ git commit -a -m "Your App"
> $ git push heroku master
This is, of course, only possible if you have added your heroku repo to your local remote repositories:
> $ git remote add heroku https://heroku.com/......
When you push your local repo to your Heroku one, Heroku then runs what's known as a buildpack:
When you git push heroku, Heroku’s slug compiler prepares your code
for execution by the Heroku dyno manager. At the heart of the slug
compiler is a collection of scripts called a buildpack.
Heroku’s Cedar
stack has no native language or framework support; Ruby, Python, Java,
Clojure, Node.js and Scala are all implemented as buildpacks.
This means that when you push your app to your repo, Heroku will endeavour to compile & run it for you. This is when the app will run.
Fix
To fix, you should follow the tutorial here
Basically, you need to get your git repo created locally, which will then provide you with the ability to push to your remote heroku repo

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.

How to reset everything Heroku in my Git/Rails 3.1 Project

I solved my problem while writing this post, but I thought this might be good information for other noobs like me :)
To solve the problem below edit the following file
.git/config
There's a section that looks like this
[remote "heroku"]
url = git#heroku.com:adjective-noun-1234.git
fetch = +refs/heads/*:refs/remotes/heroku/*
This is what git tries to push to. Just change the line
url = git#heroku.com:adjective-noun-1234.git
to whatever new Heroku project you created. Git should now be able to push to Heroku again.
I have gotten my second Rails app ever to a working state and want to deploy it. So I followed all the steps for Heroku deployment in the Ruby on Rails Tutorial (I had the deployment working for the sample app from the book) using:
heroku create
I then push my project with
git push heroku master
The project doesn't work although I can't find any errors in the Heroku logs, all I get is:
We're sorry, but something went wrong.
We've been notified about this issue and we'll take a look at it
shortly.
So I looked around the Heroku Support Section and found the official Rails 3.0 / 3.1 deployment guide:
http://devcenter.heroku.com/articles/rails3
http://devcenter.heroku.com/articles/rails31_heroku_cedar
I went to the Heroku Web Frontend > General Info > Destroy App because I wanted to continue my efforts with a clean slate.
Following the guide I created a Heroku project for the cedar stack:
heroku create --stack cedar
And push it to Heroku using
git push heroku master
THE PROBLEM: for some reason git is still trying to push to the old Heroku project!!!
resulting in an error
fatal: The remote end hung up unexpectedly
Check your remote repositories, and update it to the new heroku name:
git remote -v
Then remove the heroku one that is wrong:
git remote rm heroku
Then add the new one
git remote add heroku git#heroku.com:sitename.git
This is a bit extreme, but worked for me....
heroku destroy appname
heroku create
git push heroku master

Resources