Heroku is my favorite service to deploy my Rails apps on. It can be a simple joy to use, or it can be a complete nightmare. It’s not difficult to deploy to Heroku, but there are a few things you must keep in mind:
1. Make sure your Rails app is located in a top level directory of your git repository. If you try to create an app anywhere else, it will fail to deploy to Heroku.
2. Heroku will not work with SQLite. You need to install Postgres if you’re working with Heroku. If you’d like to continue using SQLite in development, that has to be specified in the Gemfile. Ideally, you Gemfile should look like this:
group :development, :test do
group :production do
3. Once you’ve updated your Gemfile, run
4. If this is a new repository, you’ll need to initialize it in the terminal with
5. After your repository has been initialized,
git add . and
git commit -m "Your message" .
6. Now we’re ready to push to Heroku! You’ll want to create your Heroku repo on the Cedar Stack. This is Heroku’s default runtime stack and works with Ruby, Rails, Python (and many more) languages. Run the command
heroku create --stack cedar to create your repo.
7. Finally, run
git push heroku master to push your code to heroku. You’ll notice that if you’ve been successful, Heroku gives you the URL in the terminal to visit your app.
If you already have a database in development, remember that isn’t going to be uploaded. You’ll need to run heroku
heroku run rake db:migrate to setup your database on Heroku.
That’s Heroku in a nutshell. If and when you do encounter problems updating Heroku, run
heroku logs to help identify where the problem may lie. Whenever I’ve failed to deploy successfully to Heroku it’s because something is already broken in the app, that I didn’t catch in my development environment.
Good luck and please post other questions and Heroku advice in the comments!