Sam D20
Sam D20

Reputation: 2575

/config/initializers/secret_token.rb not being generated. Why not?

Currently going through a rails tutorial and I need to make some modifications to /config/initializers/secret_token.rb, however, I can't find this file anywhere within the initializers directory. I am running the latest version of rails. This is the line I used in the terminal to create a rails project:

rails new sample_app 

Anyone know why it isn't showing up?

Upvotes: 10

Views: 8174

Answers (3)

mhartl
mhartl

Reputation: 1931

Thanks for pointing this out. The issue is probably due to using Rails 4.1 instead of Rails 4.0 as specified in the Rails Tutorial. It's because of issues like this that Section 1.2.2 states (bold in original)

Unless otherwise noted, you should use the exact versions of all software used in the tutorial, including Rails itself, if you want the same results.

To get things to work, first uninstall the current version of Rails:

$ gem uninstall rails railties

Then follow the instructions exactly as written in the tutorial to install Rails 4.0:

$ gem install rails --version 4.0.4

Generating a test app (skipping Bundler for convenience) and piping the output through grep then verifies that secret_token.rb gets generated:

$ rails -v
Rails 4.0.4
$ rails new test_app --skip-bundle | grep secret_token
      create  config/initializers/secret_token.rb

At this point, you should be able to follow the rest of the tutorial as written.

By the way, I'm about to start work on a 3rd edition of the tutorial, and will plan to take care of this issue as part of a more general update.

Upvotes: 17

frankzk
frankzk

Reputation: 566

I am using 4.1.1. Dont copy nothing to the secrets.yml, just dont forget to update the gitignore file (http://www.railstutorial.org/book/beginning#code-gitignore)

With this you can keep going on the tutorial

Upvotes: 0

sevenseacat
sevenseacat

Reputation: 25049

The tutorial you're looking at was likely written for an older version of Rails than you're using.

secret_token.rb existed in Rails 3 and Rails 4.0 apps; it does not exist in Rails 4.1 apps.

It has been replaced in Rails 4.1 by the secrets.yml file:

http://guides.rubyonrails.org/upgrading_ruby_on_rails.html#config-secrets-yml

Upvotes: 14

Related Questions