Plagiarizing from here:
http://rubylearning.com/blog/2010/12/15/getting-started-with-heroku/
http://rubysource.com/heroku-your-first-staging-environment/
If you don’t have rails and ruby already on your machine:
$ gem install bundler
// rails is installed as a gem:
$ gem install rails
NOTE: If you are in a windows machine, and have trouble at this point installing rails. You need a couple of extra steps:
– Download the latest version of Ruby, and also DevKit, from: http://rubyinstaller.org/downloads
– When prompted, extract the DevKit installation to: C:Ruby[your ruby versionDevKit
– cd to DevKit
– Run the following commands:
ruby dk.rb init
ruby dk.rb review
ruby dk.rb install
Then you can continue as if you were on a Mac or Linux setup:
$ rails new myapp
$ cd myapp
$ git init
$ git add .
$ git commit -m “initial commit”
If you want to use gitHub as your master repository:
$git remote add origin git@github.com:your-user-name/your_app.git // Origin means main repository sort of
$git push -u origin master
$ gem install heroku
// This is not completely necessary, but it may be needed on your server to create the keys that will allow connection to the server:
$ heroku keys:add
$ heroku create –stack cedar
–stack cedar optional: it gives you the latest stable version of heroku
Alternatively, you can create an staging environment as follows (instead of just “heroku create”):
$heroku create your-app-name –remote staging // Remote creates an extra git repository locally where you can push changes independent from master (OPTIONAL)
$ git push staging master // Pushes to your staging env (OPTIONAL)
$ git push heroku master
NOTE: Most likely you will run into trouble here, because Heroku uses postgres instead of litesql for its database. To get past this issue:
– Edit your Gemfile as follows:
gem 'sqlite3', :group => [:development, :test]
group :production do
gem 'thin'
gem 'pg'
end
- remove Gemfile.lock
- run ‘bundle install –without production’
- git add .
- git commit -am “Using sqlite3 in local dev environment only”
- git push heroku master
$ heroku rake db:migrate # you’ll need to do this for any schema change
Note: if you run into trouble at heroku at this point, add the following line to your Rakefile, just before “require ‘rake'”:
require ‘rake/dsl_definition’
To start using gemsets, run the following command:
$mate Gemfile (it will generate the default gem file for you)
$bundle install
And, of course, running the server:
$rails s
When you deploy to heroku, and if you forgot your temp URL, you can find out what it is by typing in the command line:
$heroku open // Open a browser with your application’s public URL