Last Updated: February 25, 2016
·
3.594K
· javier_toledo

Fast solution for 'uninitialized constant ActiveSupport::SecureRandom'

If you're having this exception after updating a Rails application to version >=3.2.X, on Ruby >1.9.X..

uninitialized constant ActiveSupport::SecureRandom

..and you don't want to debug half dozen gems until you
find which one is causing the error, you can use this hack
as Ruby's >1.9 SecureRandom API is 100% compatible with the
Rails <3.2 ActiveSupport::SecureRandom API.

Just add this line in some initializer:

ActiveSupport::SecureRandom = SecureRandom

This is absolute uglyness, but it works and I won't tell nobody
that you went so lazy to use it ;-)