#72
Sep 24, 2007

Adding an Environment

Rails comes with three environments: development, test, and production. But, you aren't restricted to just these. You can add your own! See how in this episode.
Download (7.1 MB, 3:22)
alternative download for iPod & Apple TV (4.9 MB, 3:22)
# database.yml
staging:
  adapter: mysql
  database: store_staging
  user: root
  password:
  host: localhost
# environments/staging.rb
config.log_level = :debug
mysqladmin create store_staging -u root -p
rake db:migrate RAILS_ENV=staging
script/server -e staging

RSS Feed for Episode Comments 4 comments

1. seb Sep 24, 2007 at 01:16

Great cast!
It would be great to see how to setup capistrano to use staging environment may be the next screencasts :)


2. Rich Cavanaugh Sep 24, 2007 at 06:38

I don't know about Capistrano but, I do have a solution for staging environments using Vlad on my blog.


3. Chris Barnes Oct 23, 2007 at 22:11

I've been using a custom environment for beta testing and it works really well. I can have beta testers using an edge version of my code while the production users data is unaffected. I can also give beta testers more info in their error messages.


4. Matt Nov 02, 2007 at 11:09

Thanks for the tip.

One thing that made me curious enough to dig thru the initializer code was the bit on having to set the config.log_level = :debug. This isn't necessary. The initializer only sets the log level to :info if the environment == 'production'. Otherwise, all other environments are set to :debug

Add your comment:

(SKIP THIS ONE)

(required)

(not shown)


(use pastie or gist for code)

sponsored by:
if you want to help:
required:
Get Quicktime Player