rails-secrets
rails-secrets copied to clipboard
Does not work in Rails 3.2
A secret is required to generate an integrity hash for cookie session data. Use config.secret_token = "some secret phrase of at least 30 characters"in config/initializers/secret_token.rb
config.after_initialize do |app|
if app.secrets.secret_key_base.blank?
raise "Missing `secret_key_base` for '#{Rails.env}' environment, set this value in `config/secrets.yml`"
else
app.config.secret_key_base = app.secrets.secret_key_base
end
end
Is probably the issue. Rails expects secret_token right?
An alternative way to get this to work;
Don't remove the secret_token.rb as suggested in the README, instead just change it to this.
# Be sure to restart your server when you modify this file.
# Your secret key for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
# Set token based on intialize_secret function (defined in initializers/secret_generator.rb)
RailsApp::Application.config.secret_token = Rails.application.secrets.secret_key_base
Confirmed. Doesn't work with Rails 3.2 out of the box without doing something like this. This should probably go in the readme.