How to downgrade a rails gem

This is for someone who wants to downgrade a rails gem. For example let’s take devise gem.

  1. In Gemlock file add the downgraded version you are interested in.
gem 'devise', '~> 2.5'

2. run bundle update devise

Important notes:

  1. Do not runbundle update as it updates all the gems.
  2. Never make changes directly to Gemfile.lock
  3. Make sure to restart spring if running in background.