Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
751 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...