aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/initialization.md
diff options
context:
space:
mode:
authorAlex Johnson <notalexjohnson@gmail.com>2013-11-06 18:24:22 +0530
committerAlex Johnson <notalexjohnson@gmail.com>2013-11-06 18:24:22 +0530
commitcb632188b33c2eaf7505c3df85e5ced354cbe2d2 (patch)
tree3bf3e427305e856fdbcc04a39120ee1d7a090a4a /guides/source/initialization.md
parenta5176def3d9067e1aa3bfe8457f888ed45f422c9 (diff)
downloadrails-cb632188b33c2eaf7505c3df85e5ced354cbe2d2.tar.gz
rails-cb632188b33c2eaf7505c3df85e5ced354cbe2d2.tar.bz2
rails-cb632188b33c2eaf7505c3df85e5ced354cbe2d2.zip
Update Rails initialization guide to explain how bin/rails is executed
Diffstat (limited to 'guides/source/initialization.md')
-rw-r--r--guides/source/initialization.md39
1 files changed, 36 insertions, 3 deletions
diff --git a/guides/source/initialization.md b/guides/source/initialization.md
index 7e9cb5a47d..33eb74dcd9 100644
--- a/guides/source/initialization.md
+++ b/guides/source/initialization.md
@@ -29,9 +29,42 @@ quickly.
Launch!
-------
-Let's start to boot and initialize the app. It all begins with your app's
-`bin/rails` executable. A Rails application is usually started by running
-`rails console` or `rails server`.
+Let's start to boot and initialize the app. A Rails application is usually
+started by running `rails console` or `rails server`.
+
+### `railties/bin/rails`
+
+The `rails` in the command `rails server` is a ruby executable in your load
+path. This executable contains the following lines:
+
+```ruby
+version = ">= 0"
+load Gem.bin_path('railties', 'rails', version)
+```
+
+If you try out this command in a Rails console, you would see that this loads
+`railties/bin/rails`. A part of the file `railties/bin/rails.rb` has the
+following code:
+
+```ruby
+require "rails/cli"
+```
+
+The file `railties/lib/rails/cli` in turn calls
+`Rails::AppRailsLoader.exec_app_rails`.
+
+### `railties/lib/rails/app_rails_loader.rb`
+
+The primary goal of the function `exec_app_rails` is to execute your app's
+`bin/rails`. If the current directory does not have a `bin/rails`, it will
+navigate upwards until it finds a `bin/rails` executable. Thus one can invoke a
+`rails` command from anywhere inside a rails application.
+
+For `rails server` the equivalent of the following command is executed:
+
+```bash
+$ exec ruby bin/rails server
+```
### `bin/rails`