It turns out that I just started a project in RoR and my project does not contain the file secrets.yml, I would like to know how to generate one or make the original appear that should be hidden somewhere.
It turns out that I just started a project in RoR and my project does not contain the file secrets.yml, I would like to know how to generate one or make the original 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 can also be nano
depends on which one you have installed EDITOR="nano" bin/rails credentials:edit
.
If your rails is less than 4 then here is an example of your secrets:
development:
secret_key_base: super_long_secret_key_for_development
active_merchant_login: 896667
active_merchant_password: supersecretpassword888
test:
secret_key_base: super_long_secret_key_for_test
active_merchant_login: 896667
active_merchant_password: supersecretpassword888
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
active_merchant_login: <%= ENV["AM_LOGIN"] %>
active_merchant_password: <%= ENV["AM_PASSWORD"] %>
I took it from this league
Additionally, in the production environment you must create the environment variable SECRET_KEY_BASE 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 data of the «Client ID» and the «Client Secret» It should look similar to the following
development:
spotify:
access_key_id: abc123
secret_access_key: abc123
production:
spotify:
access_key_id: abc123_
secret_access_key: abc123_
"../ config / master.key" must be added to ".gitignore" as the decryption key.
This answer is extracted from another question, the complete example with the API of spotyfy is in this link