GreenTriangle
GreenTriangle

Reputation: 2460

What is the Rails secret token and how do I set it?

I am trying to create a Rails app under Phusion Passenger, and have run into the missing secret_key_base error. I have Googled this error and found no clear explanation of what the secret token/key is, how I set it, or what it's for -- only scraps here and there all assuming that I already know something else, making it impossible to really figure out what's going on. Nor do either of the two books I bought on Rails discuss this.

What is the secret token?

What is it for?

How do I set it upon creating a new app?

Upvotes: 2

Views: 2665

Answers (1)

Robert Christopher
Robert Christopher

Reputation: 5470

Secret token is a string with random characters which looks like this

82d58d3dfb18768b495n311eb8539edf5064784h1d58994679db8363ec241c745cef0b419bfe44d66cbf91a2f4e497d8f6b1ef1226e3f405b0d263a9617ac75e

when you create a new rails application, this token is created by default and stored here <application folder>/config/initializers/secret_token.rb. This token is used to verify the integrity of signed cookies (Any cookie set by your rails application is signed using this token)

Like I pointed out, its usually created in a new rails application, but if you face any issues with the tokens, you may try creating a new token and manually pasting it your secret_token.rb file. Use this command rake secret to create a new secret token.

Upvotes: 6

Related Questions