This one’s simple. Sometimes I need to know what environment Rails is running in (for example, so I can display additional debugging information, or not link to the HTTPS version of an action), and typing out ENV['RAILS_ENV'] is a hassle and looks ugly. Hence, this plugin.
Installation
Are you down with SVN? Yeah, you know me!
./script/plugin install -x http://svn.codahale.com/rails_environments/trunk
Think source control is for the weak?
./script/plugin install http://svn.codahale.com/rails_environments/trunk
Usage
Rails Environments drops five hot new methods in your lap:
if Rails.production?
'Production'
elsif Rails.development?
'Development'
elsif Rails.test?
'Test'
elsif Rails.none?
'Oh, You Gotta Be Kidding Me'
else
"Dude, what the hell: #{Rails.environment}"
end
Not complicated, sure, but it makes my code pretty. Ponies!
4 comments »
Yes, I’m going to be rolling out quite a few Rails plugins for the next few weeks; I’ve got a bit of a backlog.
This one replaces the list of countries used by country_select and other Rails helpers with a list of countries that the United States Postal Service can send mail to. (Yes, it’s hopelessly US-centric, and I know that many countries don’t self-identify as these terms, but it’s not for use by demographers, it’s for use when you need people to specify where they want something mailed via Lance Armstrong’s old team.) The reason I put this together is to make it integrate nicely with the USPS’s shipping quote web service.
Installation
For the svn-happy:
./script/plugin install -x http://svn.codahale.com/usps_countries/trunk
For the Subversionally challenged:
./script/plugin install http://svn.codahale.com/usps_countries/trunk
Usage
This really just replaces the country listings. The one thing you’ll want to know is that the listing for the US can be found here:
USPSCountries::UNITED_STATES
There you go!
3 comments »