Best practice deployment

what is the best method to deploy from a development machine to
production

when you need slightly different files for each mode

do you use TWO files such as db.yml.dev and db.yml.prod

and use capistrano to deploy one or the other to database.yml

or is it better to have one file

and use conditions in your file such as

<% if ENV[‘RAILS_ENV’] = “production” %>
host: db.host.com
<%else%>
host: localhost:1234
<%end%>

cheers

dion

and use conditions in your file such as

<% if ENV[‘RAILS_ENV’] = “production” %>
host: db.host.com
<%else%>
host: localhost:1234
<%end%>

Well, for starters, the above will always use db.host.com since you’re
doing an assignment (=) not an equality check (==)…

But I’m not sure why you don’t just have a single database.yml file with
a
“production:” section and a “development:” section (like the default one
that is generated) and then simply set RAILS_ENV appropriately either in
the environment, fastcgi, mongrel, etc…

?

-philip

On Thu, Jul 20, 2006, Dion H. wrote:

and use conditions in your file such as

<% if ENV[‘RAILS_ENV’] = “production” %>
host: db.host.com
<%else%>
host: localhost:1234
<%end%>

Philip is right, it’s probably best to just have one database.yml and
use the environments the way they were intended. If that can’t work for
you, conditionals may be the way to do.

Three blog posts that might help you (one by me, shameless plug):

Letting Capistrano build your database.yml:
http://www.jvoorhis.com/articles/2006/07/07/managing-database-yml-with-capistrano

Conditional Rails Database Configuration:
http://duncandavidson.com/essay/2006/06/conditionalDatabaseConfig

Using two database.yml files with Capistrano:
http://blog.bleything.net/articles/2006/07/07/bending-capistrano-to-your-deployment-environment

Ben

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs