rails_habitat: a simple rails plugin to make RAILS_ENV a bit friendlier
I just released a stupid simple plugin based on the idea behind Coda Hale’s rails_environments plugin.
This plugin adds the following functionality to the Rails module to help with determining the current enviroment:
>> Rails.environment # a convenience alias to Rails.env => "development" >> Rails.development? => true >> Rails.not_development? => false >> Rails.production? => false >> Rails.not_production? => true >> Rails.test? => false >> Rails.not_test? => true
Not only does it provide env?
and not_env?
methods for the standard environments, it also provides those methods for any environment you define in config/environments/ (in fact that is how it learns about all of the environments, including the standard three). So if you define new environments in config/environments/ they will be picked up automatically.
Install with: script/plugin install git://github.com/tobias/rails_habitat.git
It lives on github.
Edit: see David’s comment below for the built in way to do this (in Rails >= 2.2).