Skip to content

Instantly share code, notes, and snippets.

@splattael
Created March 12, 2009 12:10
Show Gist options
  • Select an option

  • Save splattael/78034 to your computer and use it in GitHub Desktop.

Select an option

Save splattael/78034 to your computer and use it in GitHub Desktop.
def with_rails_env(new_value)
old = Object.send(:remove_const, 'RAILS_ENV')
Object.const_set('RAILS_ENV', new_value)
yield
ensure
Object.send(:remove_const, 'RAILS_ENV')
Object.const_set('RAILS_ENV', old)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment