This will be a short in-between post. Don’t expect to be annoyed, enlightened or even trivially entertained. I’m just going to describe two small things I do in all my Rails-projects, and I haven’t found a way to do them as plugins. This is very annoying, of course, so I hope someone from the Rails team will eventually see this and tell me how to do it DRY.
1. Add a production_test environment
I feel constrained by the three environments that get delivered by Rails out of the box. And I find that for every project where the customer isn’t myself and the codebase is bigger than about 50 lines of (hand-written) code, I tend to add a new environment to Rails; ‘production_test’. The problem this environment solves is the situation where I want my customers to test out an application, but I don’t want them to do it against a real production environment. For example, I did an application called LPW a few months back, that works against a 3rd party web service. This web service has one production environment and one test environment. I want the production_test to be as fast, responsive and generally as much as the production environment as possible, but not go against the production web service. I solve this by adding a production_test env which is exactly like the production environment, except I can just change the address to the web service endpoint to the test one.
I usually do this, so I can give my customers a nice application that they can play with, but without worrying about them damaging production data.
2. Add plugin environment configuration
This is actually a major pain. I have developed a few plugins, and generally I want them to have configurations based on which environment we are in. For example, the CAS authentication plugin shouldn’t really redirect to the CAS server when in development environment. But, I can’t set this in any good way, since the plugins will be loaded after the environment-specific files have been loaded. So, what I do is simply to add a new directory, called config/plugin and in environment.rb I have this:
plugin_environment = File.join(RAILS_ROOT,'config', 'plugin', "#{ENV['RAILS_ENV']}.rb")
load plugin_environment if File.exist?(plugin_environment)
This solution sucks, but it works.

5 Comments, Comment or Ping
Did you overlook Streamlined?
http://streamlined.relevancellc.com/
Another option to enhance Rails is RJS:
http://www.codyfauser.com
September 25th, 2006
@anon – they are good solutions for different problems
@ola – I agree that these are relevant problems.
September 26th, 2006
We use a fourth environment but call it “staging”. I can’t imagine doing any sort of deployment/rollout without it.
September 26th, 2006
i suspect anon #1 didn’t care too much about ola’s post and was more interested in page rank and the like.
September 26th, 2006
As Rob points out, the technical term for this is “staging”.
September 26th, 2006
Reply to “Two things in Rails”