However you cut it, sometimes there are differences between the development and production environments.

For example, if you are integrating your website with PayPal, you probably want your local tests in the development environment to hit, and not the main site at

In my applications, I always store the URL to the PayPal service in a Setting or Configuration object. This allows me the flexibility of changing the value whenever I need to.

Of course, I use Migrations to generate my tables, or pre-populate them with data. Here is a typical migration:

 1 class SetupPaypalConfig < ActiveRecord::Migration
 2   def self.up
 3     config = Configuration.find_or_create_by_name('paypal.url')
 4     config.value = ''
 6   end
 8   def self.down
 9     Configuration.find_or_create_by_name('paypal.url').destroy
10   end
12   class Configuration < ActiveRecord::Base; end
13 end

Nothing prevents me from keying off RAILS_ENV like this:

1 config.value = case RAILS_ENV
2                when 'development'
3                  ''
4                else
5                  ''
6                end

An alternative would be to store the PayPal URL in a constant, and initialize the constant in config/environments/*.rb. This means much less code. But in my case, I usually have a need for a configuration-like object where admins of the system can change some values.


Your Host

A picture of me

I am François Beausoleil, a Ruby on Rails and Scala developer. During the day, I work on Seevibes, a platform to measure social interactions related to TV shows. At night, I am interested many things. Read my biography.

Top Tags

Books I read and recommend


Projects I work on

Projects I worked on