Setting up a Rails project with Heroku, Eclipse and Domains

I always forget the single steps to create a new rails application that has a staging & production environment, can be deployed to Heroku and has the nameservers properly configured. So here’s the outline (so you and I never forget it):

1) Create Application

rails new $APP
cd $APP

2) Create Eclipse ./.project file

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
  <name>$APP</name>
  <buildSpec>
    <buildCommand>
      <name>com.aptana.ide.core.unifiedBuilder</name>
    </buildCommand>
  </buildSpec>
  <natures>
    <nature>org.radrails.rails.core.railsnature</nature>
    <nature>com.aptana.ruby.core.rubynature</nature>
  </natures>
</projectDescription>

3) Update Gemfile

source 'https://rubygems.org'

gem 'rails'
gem 'jquery-rails'
gem "jquery-ui-rails"
gem "anjlab-bootstrap-rails", "~> 2.0.4.4", :require => "bootstrap-rails"

group :assets do
  gem 'sass-rails'
  gem 'coffee-rails'
  gem 'uglifier'
end

group :development do
  gem 'sqlite3'
end

group :production, :staging do
  gem "pg"
  gem "therubyracer"
end

gem "devise", ">= 2.1.2"
gem "cancan", ">= 1.6.8"
gem "rolify", ">= 3.1.0"

4) Install Bundle

bundle install --without production staging

5) Clean Up

rm ./README.rdoc
rm ./public/index.html
rm ./public/favicon.ico
rm ./doc/README_FOR_APP
rm ./app/assets/images/rails.png

6) Create Root Controller

rails generate controller root index

7) Update Routes

root :to => 'root#index'

8) Create Git Repository & Init

git init
git remote add origin $URL

9) Overwrite ./.gitignore

.bundle
db/*.sqlite3*
log/*.log
*.log
/tmp/
doc/
*.swp
*~
.DS_Store

10) Commit

git add .
git commit -a -m "Initial Commit"
git push origin master

11) Create Heroku Endpoints & Push to Heroku

heroku create $APP-staging --remote staging
heroku create $APP --remote production
git push staging master
git push production master

12) Prepare Heroku Domain

heroku domains:add --app $APP www.$APP.com

13) Setup your Domain

  • Domain Forward to http://$APP.herokuapp.com
  • NameServer Settings: www.$APP.com CNAME $APP.herokuapp.com

A) References

Enhanced by Zemanta

Leave a Reply