diff options
author | Xavier Noria <fxn@hashref.com> | 2010-12-20 20:13:34 +0100 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2010-12-20 20:13:34 +0100 |
commit | 880f8419c41db0aea4b7cf3abd74fe5d32fa04a7 (patch) | |
tree | 0c21b8e0829136b6fb33a136caf3085f2a78c857 /railties/guides/source/initialization.textile | |
parent | 0cbfd6c28d327304432f7d0c067662b5c1e41a78 (diff) | |
parent | 6909fb6cff49e11574909b55864af8673d044eb7 (diff) | |
download | rails-880f8419c41db0aea4b7cf3abd74fe5d32fa04a7.tar.gz rails-880f8419c41db0aea4b7cf3abd74fe5d32fa04a7.tar.bz2 rails-880f8419c41db0aea4b7cf3abd74fe5d32fa04a7.zip |
Merge branch 'master' of git://github.com/lifo/docrails
Diffstat (limited to 'railties/guides/source/initialization.textile')
-rw-r--r-- | railties/guides/source/initialization.textile | 46 |
1 files changed, 41 insertions, 5 deletions
diff --git a/railties/guides/source/initialization.textile b/railties/guides/source/initialization.textile index 72e10191f9..6dc13930f0 100644 --- a/railties/guides/source/initialization.textile +++ b/railties/guides/source/initialization.textile @@ -31,7 +31,7 @@ The actual +rails+ command is kept in _bin/rails_ at the and goes like this: end </ruby> -This file will attempt to load +rails/cli+ and if it cannot find it then add the +railties/lib+ path to the load path (+$:+) and will then try to require it again. +This file will attempt to load +rails/cli+ and if it cannot find it then add the +railties/lib+ path to the load path (+$:+) and will then try to require it again. h4. +railites/lib/rails/cli.rb+ @@ -120,7 +120,7 @@ This climbs the directory tree until it reaches a path which contains a +script/ This is effectively the same as doing +ruby script/rails [arguments]+. Where +[arguments]+ at this point in time is simply "server". -h4. +script/rails+ +h4. +script/rails+ This file looks like this: @@ -236,7 +236,7 @@ Now back to +action_pack/lib/action_dispatch.rb+. The next +require+ in this fil After this line, there's a require to +active_model+ which simply defines autoloads for the +ActiveModel+ part of Rails and sets up the +ActiveModel+ module which is used later on. -The last of the requires is to +rack+, which like the +active_model+ and +active_support+ requires before it, sets up the +Rack+ module as well as the autoloads for constants within it. +The last of the requires is to +rack+, which like the +active_model+ and +active_support+ requires before it, sets up the +Rack+ module as well as the autoloads for constants within it. Finally in +action_dispatch.rb+ the +ActionDispatch+ module and *its* autoloads are declared. @@ -337,7 +337,7 @@ The class *is* defined in +Rack::Server+, but is overwritten in +Rails::Server+ ... </ruby> -This method will set up keys for the +options+ which Rails will then be able to use to determine how its server should run. After +initialize+ has finished, then the +start+ method will launch the server. +This method will set up keys for the +options+ which Rails will then be able to use to determine how its server should run. After +initialize+ has finished, then the +start+ method will launch the server. h4. +Rails::Server#start+ @@ -448,7 +448,7 @@ This file begins with requiring +config/application.rb+. h4. +config/application.rb+ -This file requires +config/boot.rb+, but only if it hasn't been required before, which would be the case in +rails server+ but *wouldn't* be the case with Passenger. +This file requires +config/boot.rb+, but only if it hasn't been required before, which would be the case in +rails server+ but *wouldn't* be the case with Passenger. Then the fun begins! The next line is: @@ -486,6 +486,42 @@ This file is responsible for the initial definition of the +Rails+ module and, r However, before all that takes place the +rails/ruby_version_check+ file is required first. +h4. +railties/lib/rails/ruby_version_check.rb+ + +This file simply checks if the Ruby version is less than 1.8.7 or is 1.9.1 and raises an error if that is the case. Rails 3 simply will not run on earlier versions of Ruby than 1.8.7 or 1.9.1. + +NOTE: You should always endeavour to run the latest version of Ruby with your Rails applications. The benefits are many, including security fixes and the like, and very often there is a speed increase associated with it. The caveat is that you could have code that potentially breaks on the latest version, which should be fixed to work on the latest version rather than kept around as an excuse not to upgrade. + +h4. +active_support/core_ext/kernel/reporting.rb+ + +This is the first of the many Active Support core extensions that come with Rails. This one in particular defines methods in the +Kernel+ module which is mixed in to the +Object+ class so the methods are available on +main+ and can therefore be called like this: + +<ruby> + silence_warnings do + # some code + end +</ruby> + +These methods can be used to silence STDERR responses and the +silence_stream+ allows you to also silence other streams. Additionally, this mixin allows you to suppress exceptions and capture streams. For more information see the "Silencing Warnings, Streams, and Exceptions":http://guides.rubyonrails.org/active_support_core_extensions.html#silencing-warnings-streams-and-exceptions section from the Active Support Core Extensions Guide. + +h4. +active_support/core_ext/logger.rb+ + +The next file that is required is another Active Support core extension, this time to the +Logger+ class. This begins by defining the +around_[level]+ helpers for the +Logger+ class as well as other methods such as a +datetime_format+ getter and setter for the +formatter+ object tied to a +Logger+ object. + +For more information see the "Extensions to Logger":http://guides.rubyonrails.org/active_support_core_extensions.html#extensions-to-logger section from the Active Support Core Extensions Guide. + +h4. +railties/lib/rails/application.rb+ + +The next file required by +railties/lib/rails.rb+ is +application.rb+. This file defines the +Rails::Application+ constant which the application's class defined in +config/application.rb+ in a standard Rails application depends on. Before the +Rails::Application+ class is defined however, there's some other files that get required first. + +The first of these is +active_support/core_ext/hash/reverse_merge+ which can be "read about in the Active Support Core Extensions guide":http://guides.rubyonrails.org/active_support_core_extensions.html#merging under the "Merging" section. + +h4. +active_support/file_update_checker.rb+ + +The +ActiveSupport::FileUpdateChecker+ class defined within this file is responsible for checking if a file has been updated since it was last checked. This is used for monitoring the routes file for changes during development environment runs. + + + |