I can see from here that has_secure_token
can generate a random token for a new record in a (User) model. How can I simply generate a random token without needing to do it for a model? (i.e. suppose an app has no model(s) or to put it really simply, to run some (preferably very simple) method, and it should return a random string like pX27zsMN2ViQKta1bGfLmVJE
I have tried gems SecureRandom and digest as recommended in other answers, but neither seems to bundle install successfully (the SO answers were oldish so perhaps those gems are deprecated?) - I'm using ruby 2.5.1 and rails 5.2.3
My goal is simply to generate tokens to use as keys for an API, so I essentially just need randomly generated strings that are safe to use in urls, perhaps a method that I can specify the length of the token (but I'll take what I can get for now!)