Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
795 views
in Technique[技术] by (71.8m points)

ruby on rails - /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?

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...