As pointed out in the official documentation, the simpler solution would be to simply add this to your
Important Note (Which I also overlooked) is that for this to work you will need to call
authenticate_user! method, available by default in Devise, in your controller’s
before_action:. This will call
store_location_for available out of the box in Devise, and the rest is handled by the above code in the
application_controller.rb, thus eliminating the need to rewrite code to save requesting url.