layout | title | permalink |
---|---|---|
default |
Rails Girls on Heroku |
heroku.html |
Created by Terence Lee, @hone02
Follow steps 1 through 3 of the quickstart guide to sign up, install the toolbelt, and login.
COACH: Talk about the benefits of deploying to Heroku vs traditional servers.
First, we need to get our database to work on Heroku, which uses a different database. Please change the following in the Gemfile:
{% highlight ruby %} gem 'sqlite3' {% endhighlight %}
to
{% highlight ruby %} group :development do gem 'sqlite3' end group :production do gem 'pg' end {% endhighlight %}
Run bundle install --without production
to setup your dependencies.
COACH: You can talk about RDBMS and the different ones out there.
We need to add our code to version control. You can do this by running the following in the terminal:
{% highlight sh %} git init git add . git commit -m "initial commit" {% endhighlight %}
COACH: This would be a good time to talk about version control systems and git.
We need to create our heroku app by typing heroku create --stack cedar
in the terminal and see something like this:
{% highlight sh %} Creating evening-sky-7498... done, stack is cedar http://evening-sky-7498.herokuapp.com/ | git@heroku.com:evening-sky-7498.git Git remote heroku added {% endhighlight %}
In this case "evening-sky-7498" is your app name.
Next we need to push our code to heroku by typing git push heroku master
. You'll see push output like the following:
{% highlight sh %} ounting objects: 134, done. Delta compression using up to 4 threads. Compressing objects: 100% (115/115), done. Writing objects: 100% (134/134), 35.29 KiB, done. Total 134 (delta 26), reused 0 (delta 0)
-----> Heroku receiving push -----> Ruby/Rails app detected -----> Installing dependencies using Bundler version 1.1.2 Running: bundle install --without development:test --path vendor/bundle --binstubs bin/ --deployment Fetching gem metadata from https://rubygems.org/....... ... -----> Launching... done, v4 http://evening-sky-7498.herokuapp.com deployed to Heroku {% endhighlight %}
You'll know the app is done being pushed, when you see the "Launching..." text like above.
Next we need to migrate our database like we did locally during the workshop: heroku run rake db:migrate
When that command is finished being run, you can hit the app based on the url. For this example app, you can go to http://evening-sky-7498.herokuapp.com/. You can also type heroku open
in the terminal to visit the page.