It turns out that I just started a project in RoR and my project does not contain the secrets.yml file, I would like to know how to generate one or make the original one appear that should be hidden somewhere.
It turns out that I just started a project in RoR and my project does not contain the secrets.yml file, I would like to know how to generate one or make the original one appear that should be hidden somewhere.
The secret is no longer generated in rails 5 now other files are used, if your rails is greater than 5 then you will need to use the command
EDITOR="vim" bin/rails credentials:edit
the value of your EDITOR may alsonano
depend on which one you have installedEDITOR="nano" bin/rails credentials:edit
.If your rails is less than 4 then here is an example of your secrets:
I took it from this league
Also, in a production environment you must create the SECRET_KEY_BASE environment variable and assign it a key generated by the rails secret command.
C:>rails secret 175501ea97a18f4f153b0f8df3c10a3ce97f09871bb5eb88c5ae9998b1a089c06bff6f88eb57bc94a8ff1d635ff0fa7a58df108e7e7d10c664f9234862a13714
How credentials are used in Rails 5.2 Spotify API example:
EDITOR=nano rails credentials:edit
, then add the «Client ID» data and the "Client Secret"It should look similar to the following
"../config/master.key" should be added to ".gitignore" as it is the decryption key.
This answer is extracted from another question, the complete example with the spotyfy API is in this link