Author Image
by Tin Ilijas
Apr 7th 2017
Switch users with UserSwitch

Although integration and unit tests cover most of it, a developer will still try and test it out manually. This meant we often had to go through the tedious task of logging in, logging out, remembering passwords, etc. This took a lot of our precious time which would otherwise be spent on coffee breaks meaning we had to figure out a way to speed up things. And we did speed things up… I present to you UserSwitch.


What is UserSwitch?

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.

Why UserSwitch?

Well, it’s pretty difficult and annoying to switch between users and various user roles on big projects. What UserSwitch does is make this process easy, fast and it’s pretty god damn nice. It’s also easy to plug into your existing app.

How do I get this magic thing to work?

Here in Kodius we like to keep things simple for developers so you will install this gem in no time.



    gem "bootstrap"
    gem "devise"


Add it to your app’s Gemfile and run bundle like this:

    gem "userswitch"

or you can install it manually with:

    gem install userswitch

After installing the gem you will need to create userswitch.yml template file in your config folder with this command:

    rake userswitch:create_file

Inside of this file you will set up users that are to be shown shown, edit roles and pick colors for buttons – but be very cautious, user roles need to be written exactly like user model. For example, if your model is named AdminUser then it needs to look like this:

    User: dark-blue
    AdminUser: red

And at the end just insert this inside of your view file where you want the switch buttons to show:


Voila! Just like that you are ready to switch users with UserSwitch. Have fun!

Friendly face

Contact Us

Name is required

Valid e-mail is required

Message is required

If you previously need to sign an NDA, email us at: