Skip to content

GUIDE for Deploying to heroku

Kazuya NUMATA edited this page Jun 2, 2013 · 9 revisions

application.rb

 # please activate Bundler.require... like the following.
 # The errors happen around Bourbon gem without it.
 if defined?(Bundler)
   Bundler.require(:default, :assets, Rails.env)
 end
 ...
 ...
    # Only For heroku cedar stack
    config.assets.initialize_on_precompile = false
 ...

Gemfile

source 'http://rubygems.org'

ruby '1.9.3'
gem 'rails', '3.2.8'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

# Use unicorn as the web server
# gem 'unicorn'

gem 'pg'

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

gem "i18n"
gem 'haml-rails'
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'settingslogic'
gem 'coffee-filter'
gem 'memoist'

gem 'twitter-bootstrap-rails'
gem 'dalli'
gem 'rails_emoji'
gem 'jbuilder'
gem 'underscore-rails'
gem 'doorkeeper'

config/environments/production.rb

  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    :address              => "<smtp server address>",
    :port                 => <port>, # port number. ex) 587
    :domain               => '<your heroku application name>.heroku.com',
    :user_name            => '<smtp auth user>', # smtp-auth user name
    :password             => '<smtp auth password>', # smtp-auth password
    :authentication       => 'plain', # authentication method
    :enable_starttls_auto => <true|false>  } # true if the smtp server supports TLS

config.action_mailer.default_url_options = { :host => "<your heroku application name>.heroku.com" }

Setting environment variables

Execute in console to setup the username and password for /admin/users. (You have to install heroku gem in advance.)

heroku config:add ADMIN_USER=<user name for admin>
heroku config:add ADMIN_PASSWORD=<password for ADMIN_USER>
heroku config:add OAUTH_ADMIN_USER=<user name for oauth admin>
heroku config:add OAUTH_ADMIN_PASSWORD=<password for OAUTH_ADMIN_USER>

(Optional) Memcached with dalli

On heroku.com, add 'Memcache' add-on to your application.

Add a gem in Gemfile

gem 'dalli'

Modify config.cache_store in config/environments/production.rb as follows,

config.cache_store = :dalli_store

Modify the following 2 lines in config/initializers/session_store.rb

require 'action_dispatch/middleware/session/dalli_store'
Sanataro::Application.config.session_store :dalli_store, :expire_after => 60.minutes

For Details: https://devcenter.heroku.com/articles/memcache

Trouble shooting

rake assets:precompile error

The 'user-env-compile' addon may work well (which is experimental on Jun 2nd)

heroku labs:enable user-env-compile -a <app_name>