Rails template for generating Heroku compatible Rails applications out of the box!
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
files/common
README.md
generator.rb

README.md

Heroku Rails Template

A Rails template for generating a skeleton Rails application that will deploy to Heroku with no changes and sets up the application following Heroku guidelines and best practices.

What this template does

Generates a new Rails application and then:

Common:

  • Adds rack-timeout to Gemfile (defaults to 10 secs, override via environment variable) Read More
  • Switches sqlite to postgres Read More
  • Sets up Unicorn according to Heroku guidelines (defaults to 3 processes with 30 second timeout, override via environment variable) Read More
  • Adds Procfile Read More
  • Adds .env file for local environment variables Read More
  • (Added 13 Aug 2013) Excludes .env from git via .gitignore
  • (Added 13 Aug 2013) Adds .env_sample to communicate required ENV vars to other developers
  • Removes standard database.yml replacing it with Postgres version
  • Adds newrelic.yml (You will still need to add the addon to your application) Read More
  • Add rails_12_factor to Gemfile [Read More
  • (Added 29 Aug 2013) Adds required rails_12_factor to Gemfile Read More following this changelog entry to prevent deprecation notices in logs.

Rails 4

  • (Added 05 Feb 2014) Adds sprockets_better_errors gem and enables it for development mode Read More - Only for Rails 4.0.x.x

Rails 3

  • Prevent application initializing assets on boot Read More

Usage

rails new myapp -m https://raw.github.com/johnbeynon/heroku-rails-template/master/generator.rb

Assumptions

  • You have Ruby (2.0.0) installed via either RVM or RBENV
  • Rails is already installed (confirm via $ rails -v )
  • Postgres is installed locally

Notes

If you get an error during deployment to Heroku along the lines of

rake aborted! could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?

Then you need to enable the User environment labs feature

heroku labs:enable user-env-compile -a myapp

I've found this can occur when you have certain Rails validations in your models which require a DB hit during the application initialization which occurs when assets are precompiled.

Read more about this feature here

See Also

Sister project heroku-new that adds to the Heroku CLI

heroku new:rails [APP_PATH]

rather than having to remember to type the template URL directly.