Last active
August 29, 2015 13:56
-
-
Save jsborjesson/9211178 to your computer and use it in GitHub Desktop.
Generates a new secret token in a Rails app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This oneliner generates a new secret_token.rb file, | |
| # just paste it in your terminal at the root of your project | |
| # and it will take care of the rest. | |
| echo "$(rails r "p Rails.application.class.parent_name" | sed "s/\"//g")::Application.config.secret_token = '$(rake secret)'" > ./config/initializers/secret_token.rb |
Author
Author
You can also run the no-magic version and just replace MyApp with the name of your app.
echo "MyApp::Application.config.secret_token = '$(rake secret)'" > ./config/initializers/secret_token.rb
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Explanation:
It echoes the entire contents of what needs to be in
secret_token.rbinto that file.First it finds out the name of the application, couldn't find a simple way to do this but this is what the
is for, piping to
sedjust to remove the quotes.rake secretactually generates the token value.