Saturday, October 27, 2012

Ruby Rails App on Heroku with PostgreSQL

heroku.com
Best free host for Ruby Rails

After cmd $ heroku create

Heroku provides you a PostgreSQL hence so it has to changed from SQLite before deploying it to Heroku. Follow manual given on https://devcenter.heroku.com/articles/rails3, and after $ heroku create, do some changes in file as mention below

  1. Login to heroku.com dashboard and goto newly created app.
  2. Check if Addon Heroku Postgres Dev :: Teal is added if not add it manually.
  3. Login to https://postgres.heroku.com/ and under the respective app see the connection details of database.

Change in files

Change config/database.yml for production.
 
development:
  adapter: sqlite3
  database: db/production.sqlite3
  pool: 5
  timeout: 5000
#Details from https://postgres.heroku.com/app_name
production:
  adapter: postgresql
  encoding: utf8
  reconnect: false
  database: [Replace with database_name]
  pool: 5
  username:[Replace with username]
  password: [Replace with password]
  host: [Replace with host]


Change Gemfile for production.
group :development, :test do
   gem 'sqlite3'
end

group :production do
#Specially for heroku server
  gem 'rb'
end


Please comment for any related problem..

No comments:

Post a Comment