#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 8 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


5. Anthony Ettinger Nov 13, 2008 at 15:45

Look at the multistage plugin for capistrano, it will work nicely with additional environments.


6. Ash McKenzie Jan 18, 2009 at 16:19

Just found that you cannot use the underscore character (and possibly others) in the environment name.

I was after development_home, but had to settle for developmenthome.


7. tiffany rings May 06, 2009 at 23:02

真的不错啊


8. environment Jun 05, 2009 at 12:05

Raising personal awareness of the impact everyone has on the environment is an important first step in making changes in how we use and reuse products and save energy. Reducing one's impact on the environment starts with thinking.
<a href="http://find.com/environment">environment</a>

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