UserSwitch

Gem Version

UserSwitch is a Rails plugin for switching between commonly used roles and users. It's particularly useful for development and staging environments when you often need to switch between various accounts. It saves you from the hassle of logging in or out.

alt

Example

By default, the gem will output a chain of buttons as follows

By clicking on a button, your Rails app will switch to a different user, that is, your session will change to that of a different account and save you the time you might otherwise spend clicking on logout links and filling in forms to log as a different user.

Different roles have different colors so as to be more noticeable. If we put mulitple "same role" users for testing, we can still see by color coding what role it belongs to.

alt

Requirements

gem 'bootstrap'
gem 'devise'

How to install

Add it to your app's Gemfile and run bundle

gem 'userswitch'

or install it manually

gem install userswitch

How to use

Create userswitch.yml inside you config folder with:

rake userswitch:install

Inside of your template/view, you can call users with (showing only users from yours userswitch.yml):

Userswitch.users(current_user)

The above command will generate the required HTML output to make the switching work.