No commit activity in last 3 years
No release in over 3 years
Switch from a Rails environment to another
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

Rails Env Switcher

Rails Env Switcher allows your to switch from a rails environmemnt to another one.
Best served chilled with irb-config.

Why is it useful?

We want to run tests from the rails console.

Watch the screencast

Watch the screencast!

Usage

gem 'rails-env-switcher'

If you have Pry installed, you will have access to the env command:

pafy@bisou ~/prj/rails-prj [master●] % rails c
Loading development environment (Rails 3.2.8)
~/prj/crowdtap/rails-prj (development) > env test
~/prj/crowdtap/rails-prj (test) > Rails.env
=> "test"
~/prj/crowdtap/rails-prj (test) > exit
~/prj/crowdtap/rails-prj (development) > Rails.env
=> "development"

Programmatically:

RailsEnvSwitcher.with_env 'test', :reload => true do
  # Do some stuff in the test environment
  # reload => true means that we want to reload!
  # Leaving the block returns in the original environment
  # with_env is nestable
end

# You can also switch permantently with
RailsEnvSwitcher.switch_env 'staging'

TODO

  • Middleware pattern
  • Testing

License

MIT License