diff options
author | Gaurav Sharma <gaurav2728@gmail.com> | 2016-07-07 01:54:57 +0530 |
---|---|---|
committer | Gaurav Sharma <gaurav2728@gmail.com> | 2016-07-07 01:54:57 +0530 |
commit | ef4972a3380597905845ab0c14ea46eb9f032d40 (patch) | |
tree | 8aa629c3f9df97bdc77d7e22ca8360c36d31375f /guides/source | |
parent | 478077bf4a925962f13cdaff53a31bb73383c7f4 (diff) | |
download | rails-ef4972a3380597905845ab0c14ea46eb9f032d40.tar.gz rails-ef4972a3380597905845ab0c14ea46eb9f032d40.tar.bz2 rails-ef4972a3380597905845ab0c14ea46eb9f032d40.zip |
update doc for prefer require_relative over require + File.expand_path [ci skip]
Diffstat (limited to 'guides/source')
-rw-r--r-- | guides/source/initialization.md | 8 | ||||
-rw-r--r-- | guides/source/rails_on_rack.md | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/guides/source/initialization.md b/guides/source/initialization.md index 224393d0c9..a2eec03eba 100644 --- a/guides/source/initialization.md +++ b/guides/source/initialization.md @@ -464,7 +464,7 @@ The `options[:config]` value defaults to `config.ru` which contains this: ```ruby # This file is used by Rack-based servers to start the application. -require ::File.expand_path('../config/environment', __FILE__) +require_relative 'config/environment' run <%= app_const %> ``` @@ -485,7 +485,7 @@ end The `initialize` method of `Rack::Builder` will take the block here and execute it within an instance of `Rack::Builder`. This is where the majority of the initialization process of Rails happens. The `require` line for `config/environment.rb` in `config.ru` is the first to run: ```ruby -require ::File.expand_path('../config/environment', __FILE__) +require_relative 'config/environment' ``` ### `config/environment.rb` @@ -495,7 +495,7 @@ This file is the common file required by `config.ru` (`rails server`) and Passen This file begins with requiring `config/application.rb`: ```ruby -require File.expand_path('../application', __FILE__) +require_relative 'application' ``` ### `config/application.rb` @@ -503,7 +503,7 @@ require File.expand_path('../application', __FILE__) This file requires `config/boot.rb`: ```ruby -require File.expand_path('../boot', __FILE__) +require_relative 'boot' ``` But only if it hasn't been required before, which would be the case in `rails server` diff --git a/guides/source/rails_on_rack.md b/guides/source/rails_on_rack.md index 8148f70c31..ed935e1008 100644 --- a/guides/source/rails_on_rack.md +++ b/guides/source/rails_on_rack.md @@ -64,7 +64,7 @@ To use `rackup` instead of Rails' `rails server`, you can put the following insi ```ruby # Rails.root/config.ru -require ::File.expand_path('../config/environment', __FILE__) +require_relative 'config/environment' run Rails.application ``` |