Skip to content

Instantly share code, notes, and snippets.

@jsborjesson
Last active August 29, 2015 13:56
Show Gist options
  • Select an option

  • Save jsborjesson/9211178 to your computer and use it in GitHub Desktop.

Select an option

Save jsborjesson/9211178 to your computer and use it in GitHub Desktop.
Generates a new secret token in a Rails app
# 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
@jsborjesson
Copy link
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