From fbdd72ecae9192c461794e37c76a663112dcaa6e Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Sat, 27 Nov 2010 20:47:35 +1100 Subject: Mention filter_parameters for config --- railties/guides/source/configuring.textile | 2 ++ 1 file changed, 2 insertions(+) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index ca78cc0e6d..0ea7a7bb47 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -63,6 +63,8 @@ h4. Rails General Configuration * +config.eager_load_paths+ accepts an array of paths from which Rails will eager load on boot if cache classes is enabled. All elements of this array must also be in +load_paths+. +* +config.filter_parameters+ used for filtering out the parameters that you don't want shown in the logs, such as passwords or credit card numbers. + * +config.log_level+ defines the verbosity of the Rails logger. In production mode, this defaults to +:info+. In development mode, it defaults to +:debug+. * +config.log_path+ overrides the path to the log file to use. Defaults to +log/#{environment}.log+ (e.g. log/development.log or log/production.log). -- cgit v1.2.3 From dc4dcb155589375a22c4fafea63f8bff85dd7044 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Sat, 27 Nov 2010 20:52:28 +1100 Subject: Add documentation for secret_token to config guide --- railties/guides/source/configuring.textile | 2 ++ 1 file changed, 2 insertions(+) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index 0ea7a7bb47..4677d2b983 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -81,6 +81,8 @@ h4. Rails General Configuration * +config.root+ configures the root path of the application. +* +config.secret_token+ used for specifying a key which allows sessions for the application to be verified against a known secure key to prevent tampering. + * +config.serve_static_assets+ configures Rails to serve static assets. Defaults to _true_, but in the production environment is turned off. The server software used to run the application should be used to serve the assets instead. * +config.time_zone+ sets the default time zone for the application and enables time zone awareness for Active Record. -- cgit v1.2.3 From 70abf788001ed9fa83d3e3e3f2e8520df1ab8b46 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Mon, 29 Nov 2010 11:07:36 +1100 Subject: allow_concurrency is a "global" configuration option in Rails 3 --- railties/guides/source/configuring.textile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index 4677d2b983..6fd9cca68c 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -47,6 +47,8 @@ h4. Rails General Configuration end +* +config.allow_concurrency+ should be set to +true+ to allow concurrent (threadsafe) action processing. Set to +false+ by default. You probably don't want to call this one directly, though, because a series of other adjustments need to be made for threadsafe mode to work properly. Can also be enabled with +threadsafe!+. + * +config.app_generators+ alternate name for +config.generators+. See the "Configuring Generators" section below for how to use this. * +config.autoload_once_paths+ accepts an array of paths from which Rails will automatically load from only once. All elements of this array must also be in +autoload_paths+. @@ -208,8 +210,6 @@ h4. Configuring Action Controller * +config.action_controller.consider_all_requests_local+ is generally set to +true+ during development and +false+ during production; if it is set to +true+, then any error will cause detailed debugging information to be dumped in the HTTP response. For finer-grained control, set this to +false+ and implement +local_request?+ to specify which requests should provide debugging information on errors. -* +config.action_controller.allow_concurrency+ should be set to +true+ to allow concurrent (threadsafe) action processing. Set to +false+ by default. You probably don't want to call this one directly, though, because a series of other adjustments need to be made for threadsafe mode to work properly. Instead, you should simply call +config.threadsafe!+ inside your +production.rb+ file, which makes all the necessary adjustments. - WARNING: Threadsafe operation is incompatible with the normal workings of development mode Rails. In particular, automatic dependency loading and class reloading are automatically disabled when you call +config.threadsafe!+. * +config.action_controller.default_charset+ specifies the default character set for all renders. The default is "utf-8". -- cgit v1.2.3 From d7ac3992d53e48c753b00c4e54ce24f890ca7974 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Mon, 29 Nov 2010 11:07:55 +1100 Subject: Mention threadsafe! method in config guide --- railties/guides/source/configuring.textile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index 6fd9cca68c..b87bd429de 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -55,13 +55,13 @@ h4. Rails General Configuration * +config.autoload_paths+ accepts an array of additional paths to prepend to the load path. By default, all app, lib, vendor and mock paths are included in this list. -* +config.cache_classes+ controls whether or not application classes should be reloaded on each request. Defaults to _true_ in development, _false_ in test and production. +* +config.cache_classes+ controls whether or not application classes should be reloaded on each request. Defaults to _true_ in development, _false_ in test and production. Can also be enabled with +threadsafe!+. * +config.cache_store+ configures which cache store to use for Rails caching. Options include +:memory_store+, +:file_store+, +:mem_cache_store+ or the name of your own custom class. * +config.colorize_logging+ (true by default) specifies whether or not to use ANSI color codes when logging information. -* +config.dependency_loading+ enables or disables dependency loading during the request cycle. Setting dependency_loading to _true_ will allow new classes to be loaded during a request and setting it to _false_ will disable this behavior. +* +config.dependency_loading+ enables or disables dependency loading during the request cycle. Setting dependency_loading to _true_ will allow new classes to be loaded during a request and setting it to _false_ will disable this behavior. Can also be enabled with +threadsafe!+. * +config.eager_load_paths+ accepts an array of paths from which Rails will eager load on boot if cache classes is enabled. All elements of this array must also be in +load_paths+. @@ -77,7 +77,7 @@ h4. Rails General Configuration * +config.plugins+ accepts the list of plugins to load. If this is set to nil, all plugins will be loaded. If this is set to [], no plugins will be loaded. Otherwise, plugins will be loaded in the order specified. -* +config.preload_frameworks+ enables or disables preloading all frameworks at startup. +* +config.preload_frameworks+ enables or disables preloading all frameworks at startup. Can also be enabled with +threadsafe!+. * +config.reload_plugins+ enables or disables plugin reloading. @@ -87,6 +87,8 @@ h4. Rails General Configuration * +config.serve_static_assets+ configures Rails to serve static assets. Defaults to _true_, but in the production environment is turned off. The server software used to run the application should be used to serve the assets instead. +* +config.threadsafe!+ enables +allow_concurrency+, +cache_classes+, +dependency_loading+ and +preload_frameworks+ to make the application threadsafe. + * +config.time_zone+ sets the default time zone for the application and enables time zone awareness for Active Record. * +config.whiny_nils+ enables or disabled warnings when an methods of nil are invoked. Defaults to _false_. -- cgit v1.2.3 From f03aa05cee96f0a0e09af0e9244a9cf9fcd1cf6f Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Mon, 29 Nov 2010 11:46:15 +1100 Subject: Change coloriz_logging description to follow the standard for this guide --- railties/guides/source/configuring.textile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index b87bd429de..214674ef36 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -59,7 +59,8 @@ h4. Rails General Configuration * +config.cache_store+ configures which cache store to use for Rails caching. Options include +:memory_store+, +:file_store+, +:mem_cache_store+ or the name of your own custom class. -* +config.colorize_logging+ (true by default) specifies whether or not to use ANSI color codes when logging information. +* +config.colorize_logging+ specifies whether or not to use ANSI color codes when logging information. Defaults to _true_. + * +config.dependency_loading+ enables or disables dependency loading during the request cycle. Setting dependency_loading to _true_ will allow new classes to be loaded during a request and setting it to _false_ will disable this behavior. Can also be enabled with +threadsafe!+. -- cgit v1.2.3 From b62d5d62e93ee0ad7b4500e4c351f98d9c685abd Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Mon, 29 Nov 2010 11:47:06 +1100 Subject: Move consider_all_requests_local to global config methods in config guide --- railties/guides/source/configuring.textile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index 214674ef36..e206d1d16b 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -61,6 +61,7 @@ h4. Rails General Configuration * +config.colorize_logging+ specifies whether or not to use ANSI color codes when logging information. Defaults to _true_. +* +config.consider_all_requests_local+ is generally set to +true+ during development and +false+ during production; if it is set to +true+, then any error will cause detailed debugging information to be dumped in the HTTP response. For finer-grained control, set this to +false+ and implement +local_request?+ in controllers to specify which requests should provide debugging information on errors. * +config.dependency_loading+ enables or disables dependency loading during the request cycle. Setting dependency_loading to _true_ will allow new classes to be loaded during a request and setting it to _false_ will disable this behavior. Can also be enabled with +threadsafe!+. @@ -211,8 +212,6 @@ h4. Configuring Action Controller * +config.action_controller.asset_path+ allows you to override the default asset path generation by providing your own instructions. -* +config.action_controller.consider_all_requests_local+ is generally set to +true+ during development and +false+ during production; if it is set to +true+, then any error will cause detailed debugging information to be dumped in the HTTP response. For finer-grained control, set this to +false+ and implement +local_request?+ to specify which requests should provide debugging information on errors. - WARNING: Threadsafe operation is incompatible with the normal workings of development mode Rails. In particular, automatic dependency loading and class reloading are automatically disabled when you call +config.threadsafe!+. * +config.action_controller.default_charset+ specifies the default character set for all renders. The default is "utf-8". -- cgit v1.2.3 From 0d32572275f066099e472f37ca2e6262e8c07bf5 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Mon, 29 Nov 2010 11:54:48 +1100 Subject: Move threadsafe warning to threadsafe's new location in config guide --- railties/guides/source/configuring.textile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index e206d1d16b..6272d81d7f 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -91,6 +91,8 @@ h4. Rails General Configuration * +config.threadsafe!+ enables +allow_concurrency+, +cache_classes+, +dependency_loading+ and +preload_frameworks+ to make the application threadsafe. +WARNING: Threadsafe operation is incompatible with the normal workings of development mode Rails. In particular, automatic dependency loading and class reloading are automatically disabled when you call +config.threadsafe!+. + * +config.time_zone+ sets the default time zone for the application and enables time zone awareness for Active Record. * +config.whiny_nils+ enables or disabled warnings when an methods of nil are invoked. Defaults to _false_. @@ -212,8 +214,6 @@ h4. Configuring Action Controller * +config.action_controller.asset_path+ allows you to override the default asset path generation by providing your own instructions. -WARNING: Threadsafe operation is incompatible with the normal workings of development mode Rails. In particular, automatic dependency loading and class reloading are automatically disabled when you call +config.threadsafe!+. - * +config.action_controller.default_charset+ specifies the default character set for all renders. The default is "utf-8". * +config.action_controller.logger+ accepts a logger conforming to the interface of Log4r or the default Ruby 1.8+ Logger class, which is then used to log information from Action Controller. Set to nil to disable logging. -- cgit v1.2.3 From 945d714e75701890bf68b70c08d0e4836a1b3ffb Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Mon, 29 Nov 2010 12:05:23 +1100 Subject: Mention controller_paths in the config guide --- railties/guides/source/configuring.textile | 2 ++ 1 file changed, 2 insertions(+) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index 6272d81d7f..891c4f1c4d 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -63,6 +63,8 @@ h4. Rails General Configuration * +config.consider_all_requests_local+ is generally set to +true+ during development and +false+ during production; if it is set to +true+, then any error will cause detailed debugging information to be dumped in the HTTP response. For finer-grained control, set this to +false+ and implement +local_request?+ in controllers to specify which requests should provide debugging information on errors. +* +config.controller_paths+ configures where Rails can find controllers for this application. + * +config.dependency_loading+ enables or disables dependency loading during the request cycle. Setting dependency_loading to _true_ will allow new classes to be loaded during a request and setting it to _false_ will disable this behavior. Can also be enabled with +threadsafe!+. * +config.eager_load_paths+ accepts an array of paths from which Rails will eager load on boot if cache classes is enabled. All elements of this array must also be in +load_paths+. -- cgit v1.2.3 From e15b8fa0901a5efb6ca1223d7331233b6e3af1f6 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Mon, 29 Nov 2010 12:18:47 +1100 Subject: No more app_generators method in 3.1 --- railties/guides/source/configuring.textile | 2 -- 1 file changed, 2 deletions(-) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index 891c4f1c4d..a610f49282 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -49,8 +49,6 @@ h4. Rails General Configuration * +config.allow_concurrency+ should be set to +true+ to allow concurrent (threadsafe) action processing. Set to +false+ by default. You probably don't want to call this one directly, though, because a series of other adjustments need to be made for threadsafe mode to work properly. Can also be enabled with +threadsafe!+. -* +config.app_generators+ alternate name for +config.generators+. See the "Configuring Generators" section below for how to use this. - * +config.autoload_once_paths+ accepts an array of paths from which Rails will automatically load from only once. All elements of this array must also be in +autoload_paths+. * +config.autoload_paths+ accepts an array of additional paths to prepend to the load path. By default, all app, lib, vendor and mock paths are included in this list. -- cgit v1.2.3 From 549c13466072d5c33fe808d25adfa06bd5feb6c8 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Mon, 29 Nov 2010 12:24:41 +1100 Subject: Add asset_host and asset_path to the configuring guide --- railties/guides/source/configuring.textile | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index a610f49282..5ae4a53973 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -49,6 +49,14 @@ h4. Rails General Configuration * +config.allow_concurrency+ should be set to +true+ to allow concurrent (threadsafe) action processing. Set to +false+ by default. You probably don't want to call this one directly, though, because a series of other adjustments need to be made for threadsafe mode to work properly. Can also be enabled with +threadsafe!+. +* +config.asset_host+ sets the host for the assets. Useful when CDNs are used for hosting assets rather than the application server itself. + +* +config.asset_path+ takes a block which configures where assets can be found. + + + config.asset_path = proc { |asset_path| "assets/#{asset_path}" } + + * +config.autoload_once_paths+ accepts an array of paths from which Rails will automatically load from only once. All elements of this array must also be in +autoload_paths+. * +config.autoload_paths+ accepts an array of additional paths to prepend to the load path. By default, all app, lib, vendor and mock paths are included in this list. -- cgit v1.2.3 From b89ce3e67961e6e090403f99b0b696f252da14d4 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Mon, 29 Nov 2010 13:10:51 +1100 Subject: Mention encoding in config guide --- railties/guides/source/configuring.textile | 2 ++ 1 file changed, 2 insertions(+) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index 5ae4a53973..40d09f8941 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -75,6 +75,8 @@ h4. Rails General Configuration * +config.eager_load_paths+ accepts an array of paths from which Rails will eager load on boot if cache classes is enabled. All elements of this array must also be in +load_paths+. +* +config.encoding+ sets up the application-wide encoding. Defaults to UTF-8. + * +config.filter_parameters+ used for filtering out the parameters that you don't want shown in the logs, such as passwords or credit card numbers. * +config.log_level+ defines the verbosity of the Rails logger. In production mode, this defaults to +:info+. In development mode, it defaults to +:debug+. -- cgit v1.2.3 From 245ce774bf4e428bb608d0d880f711c3c4153821 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Mon, 29 Nov 2010 13:11:27 +1100 Subject: Add mention of helper_paths to config guide --- railties/guides/source/configuring.textile | 2 ++ 1 file changed, 2 insertions(+) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index 40d09f8941..05afc4f7ea 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -79,6 +79,8 @@ h4. Rails General Configuration * +config.filter_parameters+ used for filtering out the parameters that you don't want shown in the logs, such as passwords or credit card numbers. +* +config.helper_paths+ configures where Rails can find helpers for this application. + * +config.log_level+ defines the verbosity of the Rails logger. In production mode, this defaults to +:info+. In development mode, it defaults to +:debug+. * +config.log_path+ overrides the path to the log file to use. Defaults to +log/#{environment}.log+ (e.g. log/development.log or log/production.log). -- cgit v1.2.3 From b9fde2fb757ffdc19bfdf170f20bdfbd10b487f9 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Mon, 29 Nov 2010 13:11:53 +1100 Subject: Reorder logger and middleware global config options --- railties/guides/source/configuring.textile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index 05afc4f7ea..9c3e0c38a8 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -85,10 +85,10 @@ h4. Rails General Configuration * +config.log_path+ overrides the path to the log file to use. Defaults to +log/#{environment}.log+ (e.g. log/development.log or log/production.log). -* +config.middleware+ allows you to configure the application's middleware. This is covered in depth in the "Configuring Middleware" section below. - * +config.logger+ accepts a logger conforming to the interface of Log4r or the default Ruby 1.8+ Logger class, which is then used to log information from Action Controller. Set to nil to disable logging. +* +config.middleware+ allows you to configure the application's middleware. This is covered in depth in the "Configuring Middleware" section below. + * +config.plugins+ accepts the list of plugins to load. If this is set to nil, all plugins will be loaded. If this is set to [], no plugins will be loaded. Otherwise, plugins will be loaded in the order specified. * +config.preload_frameworks+ enables or disables preloading all frameworks at startup. Can also be enabled with +threadsafe!+. -- cgit v1.2.3 From 685353afc7ddfd58ce99249763a2c08d44d4df5c Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Mon, 29 Nov 2010 13:30:11 +1100 Subject: asset_host and asset_path are now set at the global level --- railties/guides/source/configuring.textile | 4 ---- 1 file changed, 4 deletions(-) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index 9c3e0c38a8..38226e750a 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -222,10 +222,6 @@ h4. Configuring Action Controller config.action_controller includes a number of configuration settings: -* +config.action_controller.asset_host+ provides a string that is prepended to all of the URL-generating helpers in +AssetHelper+. This is designed to allow moving all javascript, CSS, and image files to a separate asset host. - -* +config.action_controller.asset_path+ allows you to override the default asset path generation by providing your own instructions. - * +config.action_controller.default_charset+ specifies the default character set for all renders. The default is "utf-8". * +config.action_controller.logger+ accepts a logger conforming to the interface of Log4r or the default Ruby 1.8+ Logger class, which is then used to log information from Action Controller. Set to nil to disable logging. -- cgit v1.2.3 From 390de62cacb6b3c89916b1146cdf204a5bab0703 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Mon, 29 Nov 2010 14:10:36 +1100 Subject: Fix documentation regarding the initialization events of the Rails stack --- railties/guides/source/configuring.textile | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index 38226e750a..3a49d42aaf 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -316,25 +316,22 @@ There are a few configuration options available in Active Support: * +ActiveSupport::Logger.silencer+ is set to +false+ to disable the ability to silence logging in a block. The default is +true+. -h3. Using Initializers +h3. Initialization events -After loading the framework and any gems and plugins in your application, Rails turns to loading initializers. An initializer is any file of Ruby code stored under +config/initializers+ in your application. You can use initializers to hold configuration settings that should be made after all of the frameworks and plugins are loaded. - -NOTE: You can use subfolders to organize your initializers if you like, because Rails will look into the whole file hierarchy from the +initializers+ folder on down. +Rails has 4 initialization events which can be hooked into (listed in order that they are ran): -TIP: If you have any ordering dependency in your initializers, you can control the load order by naming. For example, +01_critical.rb+ will be loaded before +02_normal.rb+. +* +before_configuration+: This is run as soon as the application constant inherits from +Rails::Application+. The +config+ calls are evaluated before this happens. +* +before_eager_load+: This is run directly before eager loading occurs, which is the default behaviour for the _production_ environment and not for the +development+ enviroment. +* +before_initialize+ This is run directly before the initialization process of the application occurs. +* +after_initialize+ Run directly after the initialization of the application, but before the application initializers are run. -h3. Using an After-Initializer +WARNING: Some parts of your application, notably observers and routing, are not yet set up at the point where the +after_initialize+ block is called. -After-initializers are run (as you might guess) after any initializers are loaded. You can supply an +after_initialize+ block (or an array of such blocks) by setting up +config.after_initialize+ in any of the Rails configuration files: +After loading the framework and any gems and plugins in your application, Rails turns to loading initializers. An initializer is any file of Ruby code stored under +config/initializers+ in your application. You can use initializers to hold configuration settings that should be made after all of the frameworks and plugins are loaded. - -config.after_initialize do - SomeClass.init -end - +NOTE: You can use subfolders to organize your initializers if you like, because Rails will look into the whole file hierarchy from the +initializers+ folder on down. -WARNING: Some parts of your application, notably observers and routing, are not yet set up at the point where the +after_initialize+ block is called. +TIP: If you have any ordering dependency in your initializers, you can control the load order by naming. For example, +01_critical.rb+ will be loaded before +02_normal.rb+. h3. Rails Environment Settings -- cgit v1.2.3 From c4cbf733a1a3fe0ab46cc707d6793e3b2de56f60 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Mon, 29 Nov 2010 17:55:12 +1100 Subject: re-add config.action_controller.asset_host and asset_path to config guide --- railties/guides/source/configuring.textile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index 3a49d42aaf..47b6742f8b 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -49,9 +49,9 @@ h4. Rails General Configuration * +config.allow_concurrency+ should be set to +true+ to allow concurrent (threadsafe) action processing. Set to +false+ by default. You probably don't want to call this one directly, though, because a series of other adjustments need to be made for threadsafe mode to work properly. Can also be enabled with +threadsafe!+. -* +config.asset_host+ sets the host for the assets. Useful when CDNs are used for hosting assets rather than the application server itself. +* +config.asset_host+ sets the host for the assets. Useful when CDNs are used for hosting assets rather than the application server itself. Shorter version of +config.action_controller.asset_host+. -* +config.asset_path+ takes a block which configures where assets can be found. +* +config.asset_path+ takes a block which configures where assets can be found. Shorter version of +config.action_controller.asset_path+. config.asset_path = proc { |asset_path| "assets/#{asset_path}" } @@ -222,6 +222,10 @@ h4. Configuring Action Controller config.action_controller includes a number of configuration settings: +* +config.action_controller.asset_host+ sets the host for the assets. Useful when CDNs are used for hosting assets rather than the application server itself. + +* +config.action_controller.asset_path+ takes a block which configures where assets can be found. Shorter version of +config.action_controller.asset_path+. + * +config.action_controller.default_charset+ specifies the default character set for all renders. The default is "utf-8". * +config.action_controller.logger+ accepts a logger conforming to the interface of Log4r or the default Ruby 1.8+ Logger class, which is then used to log information from Action Controller. Set to nil to disable logging. -- cgit v1.2.3 From 15cfaa0a3634b23477f74dbfd1fafd351933e17c Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Mon, 29 Nov 2010 18:27:23 +1100 Subject: Add documentation for page_cache_directory and page_cache_extension to config guide --- railties/guides/source/configuring.textile | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index 47b6742f8b..ab9dd220bd 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -226,6 +226,10 @@ h4. Configuring Action Controller * +config.action_controller.asset_path+ takes a block which configures where assets can be found. Shorter version of +config.action_controller.asset_path+. +* +config.action_controller.page_cache_directory+ should be the document root for the web server and is set using Base.page_cache_directory = "/document/root". For Rails, this directory has already been set to Rails.public_path (which is usually set to Rails.root + "/public"). Changing this setting can be useful to avoid naming conflicts with files in public/, but doing so will likely require configuring your web server to look in the new location for cached files. + +* +config.action_controller.page_cache_extension+ configures the extension used for cached pages saved to +page_cache_directory+. Defaults to +.html+ + * +config.action_controller.default_charset+ specifies the default character set for all renders. The default is "utf-8". * +config.action_controller.logger+ accepts a logger conforming to the interface of Log4r or the default Ruby 1.8+ Logger class, which is then used to log information from Action Controller. Set to nil to disable logging. -- cgit v1.2.3 From 477d17b31682a7f7f7718ef9fd98e65888c990bc Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Mon, 29 Nov 2010 18:30:01 +1100 Subject: Add perform_caching to config guide --- railties/guides/source/configuring.textile | 2 ++ 1 file changed, 2 insertions(+) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index ab9dd220bd..fcf7ba0ae5 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -230,6 +230,8 @@ h4. Configuring Action Controller * +config.action_controller.page_cache_extension+ configures the extension used for cached pages saved to +page_cache_directory+. Defaults to +.html+ +* +config.action_controller.perform_caching+ configures whether the application should perform caching or not. Set to _false_ in development mode, _true_ in production. + * +config.action_controller.default_charset+ specifies the default character set for all renders. The default is "utf-8". * +config.action_controller.logger+ accepts a logger conforming to the interface of Log4r or the default Ruby 1.8+ Logger class, which is then used to log information from Action Controller. Set to nil to disable logging. -- cgit v1.2.3 From 949eb91d0e771c14218f34f14cb4f00c09af60db Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Thu, 2 Dec 2010 08:36:25 +1100 Subject: Add missing colons on the end of before_initialize and after_initialize documentation in configuring guide --- railties/guides/source/configuring.textile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index fcf7ba0ae5..a3e6f0b9be 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -332,8 +332,8 @@ Rails has 4 initialization events which can be hooked into (listed in order that * +before_configuration+: This is run as soon as the application constant inherits from +Rails::Application+. The +config+ calls are evaluated before this happens. * +before_eager_load+: This is run directly before eager loading occurs, which is the default behaviour for the _production_ environment and not for the +development+ enviroment. -* +before_initialize+ This is run directly before the initialization process of the application occurs. -* +after_initialize+ Run directly after the initialization of the application, but before the application initializers are run. +* +before_initialize+: This is run directly before the initialization process of the application occurs. +* +after_initialize+: Run directly after the initialization of the application, but before the application initializers are run. WARNING: Some parts of your application, notably observers and routing, are not yet set up at the point where the +after_initialize+ block is called. -- cgit v1.2.3 From 32026b5867182dccbeeefb36728da4b0ce7b8b99 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Thu, 2 Dec 2010 15:22:25 +1100 Subject: Add mention of config.to_prepare in configuring guide --- railties/guides/source/configuring.textile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index a3e6f0b9be..2482e64f70 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -331,8 +331,9 @@ h3. Initialization events Rails has 4 initialization events which can be hooked into (listed in order that they are ran): * +before_configuration+: This is run as soon as the application constant inherits from +Rails::Application+. The +config+ calls are evaluated before this happens. -* +before_eager_load+: This is run directly before eager loading occurs, which is the default behaviour for the _production_ environment and not for the +development+ enviroment. * +before_initialize+: This is run directly before the initialization process of the application occurs. +* +to_prepare+: Run after the initializers are ran for all Railties, but before eager loading and the middleware stack is built. +* +before_eager_load+: This is run directly before eager loading occurs, which is the default behaviour for the _production_ environment and not for the +development+ enviroment. * +after_initialize+: Run directly after the initialization of the application, but before the application initializers are run. WARNING: Some parts of your application, notably observers and routing, are not yet set up at the point where the +after_initialize+ block is called. -- cgit v1.2.3 From 9cbdbd59d1b16772b55891cdb1da975855bd90c4 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Thu, 2 Dec 2010 15:48:00 +1100 Subject: Config guide: Rails has *5* initialization events --- railties/guides/source/configuring.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index 2482e64f70..f3ac3257c9 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -328,7 +328,7 @@ There are a few configuration options available in Active Support: h3. Initialization events -Rails has 4 initialization events which can be hooked into (listed in order that they are ran): +Rails has 5 initialization events which can be hooked into (listed in order that they are ran): * +before_configuration+: This is run as soon as the application constant inherits from +Rails::Application+. The +config+ calls are evaluated before this happens. * +before_initialize+: This is run directly before the initialization process of the application occurs. -- cgit v1.2.3 From a3a50a0336cbb86fd77c3a793c98f52c55f3da1c Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Thu, 2 Dec 2010 17:12:59 +1100 Subject: Configuring guide: Adding mention of the initializer method. --- railties/guides/source/configuring.textile | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index f3ac3257c9..710faa6585 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -332,13 +332,33 @@ Rails has 5 initialization events which can be hooked into (listed in order that * +before_configuration+: This is run as soon as the application constant inherits from +Rails::Application+. The +config+ calls are evaluated before this happens. * +before_initialize+: This is run directly before the initialization process of the application occurs. -* +to_prepare+: Run after the initializers are ran for all Railties, but before eager loading and the middleware stack is built. +* +to_prepare+: Run after the initializers are ran for all Railties (including the application itself), but before eager loading and the middleware stack is built. * +before_eager_load+: This is run directly before eager loading occurs, which is the default behaviour for the _production_ environment and not for the +development+ enviroment. * +after_initialize+: Run directly after the initialization of the application, but before the application initializers are run. + WARNING: Some parts of your application, notably observers and routing, are not yet set up at the point where the +after_initialize+ block is called. -After loading the framework and any gems and plugins in your application, Rails turns to loading initializers. An initializer is any file of Ruby code stored under +config/initializers+ in your application. You can use initializers to hold configuration settings that should be made after all of the frameworks and plugins are loaded. +Rails has several initializers that run on startup that are all defined by using the +initializer+ method from +Rails::Railtie+. Here's an example of the +initialize_whiny_nils+ initializer from Active Support: + + + initializer "active_support.initialize_whiny_nils" do |app| + require 'active_support/whiny_nil' if app.config.whiny_nils + end + + + +The +initializer+ method takes three arguments with the first being the name for the initializer and the second being an options hash (not shown here) and the third being a block. The +:before+ key in the options hash can be specified to specify which initializer this new initializer must run before, and the +:after+ key will specify which initializer to run this initializer _after_. + +Initializers defined using the +initializer+ method will be ran in the order they are defined in, with the exception of ones that use the +:before+ or +:after+ methods. + +WARNING: You may put your initializer before or after any other initializer in the chain, as long as it is logical. Say you have 4 initializers called "one" through "four" (defined in that order) and you define "four" to go _before_ "four" but _after_ "three", that just isn't logical and Rails will not be able to determine your initializer order. + +The block's argument of the +initialize+ is the instance of the application itself, and so we can access the configuration on it by using the +config+ method as this initializer does. + +h4. Initializer files + +After loading the framework and any gems and plugins in your application, Rails turns to loading initialization code from +config/initializers+. The files in this directory can be used to hold configuration settings that should be made after all of the frameworks and plugins are loaded. NOTE: You can use subfolders to organize your initializers if you like, because Rails will look into the whole file hierarchy from the +initializers+ folder on down. -- cgit v1.2.3 From 6349f5caaed1e20477296d54f0c1850cc358323e Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Thu, 2 Dec 2010 17:19:32 +1100 Subject: Move Rails Environment settings to above the initialization events in the config guide --- railties/guides/source/configuring.textile | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index 710faa6585..934080d60f 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -326,6 +326,19 @@ There are a few configuration options available in Active Support: * +ActiveSupport::Logger.silencer+ is set to +false+ to disable the ability to silence logging in a block. The default is +true+. + +h3. Rails Environment Settings + +Some parts of Rails can also be configured externally by supplying environment variables. The following environment variables are recognized by various parts of Rails: + +* +ENV['RAILS_ENV']+ defines the Rails environment (production, development, test, and so on) that Rails will run under. + +* +ENV['RAILS_RELATIVE_URL_ROOT']+ is used by the routing code to recognize URLs when you deploy your application to a subdirectory. + +* +ENV["RAILS_ASSET_ID"]+ will override the default cache-busting timestamps that Rails generates for downloadable assets. + +* +ENV["RAILS_CACHE_ID"]+ and +ENV["RAILS_APP_VERSION"]+ are used to generate expanded cache keys in Rails' caching code. This allows you to have multiple separate caches from the same application. + h3. Initialization events Rails has 5 initialization events which can be hooked into (listed in order that they are ran): @@ -364,18 +377,6 @@ NOTE: You can use subfolders to organize your initializers if you like, because TIP: If you have any ordering dependency in your initializers, you can control the load order by naming. For example, +01_critical.rb+ will be loaded before +02_normal.rb+. -h3. Rails Environment Settings - -Some parts of Rails can also be configured externally by supplying environment variables. The following environment variables are recognized by various parts of Rails: - -* +ENV['RAILS_ENV']+ defines the Rails environment (production, development, test, and so on) that Rails will run under. - -* +ENV['RAILS_RELATIVE_URL_ROOT']+ is used by the routing code to recognize URLs when you deploy your application to a subdirectory. - -* +ENV["RAILS_ASSET_ID"]+ will override the default cache-busting timestamps that Rails generates for downloadable assets. - -* +ENV["RAILS_CACHE_ID"]+ and +ENV["RAILS_APP_VERSION"]+ are used to generate expanded cache keys in Rails' caching code. This allows you to have multiple separate caches from the same application. - h3. Changelog * November 26, 2010: Removed all config settings not available in Rails 3 (Ryan Bigg) -- cgit v1.2.3 From 3dfcbe8d2c20e3a44805c1294459babfa8ede0db Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Thu, 2 Dec 2010 17:22:00 +1100 Subject: Config guide: separate the initialization events and initializer method documentation --- railties/guides/source/configuring.textile | 2 ++ 1 file changed, 2 insertions(+) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index 934080d60f..4f7ac60b87 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -352,6 +352,8 @@ Rails has 5 initialization events which can be hooked into (listed in order that WARNING: Some parts of your application, notably observers and routing, are not yet set up at the point where the +after_initialize+ block is called. +h4. +Rails::Railtie#initializer+ + Rails has several initializers that run on startup that are all defined by using the +initializer+ method from +Rails::Railtie+. Here's an example of the +initialize_whiny_nils+ initializer from Active Support: -- cgit v1.2.3 From e8ee2ba6cbbbc892a9db53420b8f0451a00388b0 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Thu, 2 Dec 2010 17:28:48 +1100 Subject: Config guide: Add config.active_support.bare --- railties/guides/source/configuring.textile | 2 ++ 1 file changed, 2 insertions(+) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index 4f7ac60b87..7e40cad040 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -316,6 +316,8 @@ h4. Configuring Active Support There are a few configuration options available in Active Support: +* +config.active_support.bare+ enables or disables the loading of +active_support/all+ when booting Rails. Defaults to +nil+, which means +active_support/all+ is loaded. + * +config.active_support.escape_html_entities_in_json+ enables or disables the escaping of HTML entities in JSON serialization. Defaults to +true+. * +config.active_support.use_standard_json_time_format+ enables or disables serializing dates to ISO 8601 format. Defaults to +false+. -- cgit v1.2.3 From 2e021ef477dd7d26ca6183b4e3113be3fcc6a5e1 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Fri, 3 Dec 2010 11:57:42 +1100 Subject: Clarify that preload_frameworks defaults to nil --- railties/guides/source/configuring.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index 7e40cad040..3ea9db2373 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -91,7 +91,7 @@ h4. Rails General Configuration * +config.plugins+ accepts the list of plugins to load. If this is set to nil, all plugins will be loaded. If this is set to [], no plugins will be loaded. Otherwise, plugins will be loaded in the order specified. -* +config.preload_frameworks+ enables or disables preloading all frameworks at startup. Can also be enabled with +threadsafe!+. +* +config.preload_frameworks+ enables or disables preloading all frameworks at startup. Can also be enabled with +threadsafe!+. Defaults to +nil+, so is disabled. * +config.reload_plugins+ enables or disables plugin reloading. -- cgit v1.2.3 From 4d11af2e8fa76b32e7480938c85037d907da3ae9 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Fri, 3 Dec 2010 12:16:08 +1100 Subject: Config guide: clarify what cache_store defaults to. --- railties/guides/source/configuring.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index 3ea9db2373..7475575e31 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -63,7 +63,7 @@ h4. Rails General Configuration * +config.cache_classes+ controls whether or not application classes should be reloaded on each request. Defaults to _true_ in development, _false_ in test and production. Can also be enabled with +threadsafe!+. -* +config.cache_store+ configures which cache store to use for Rails caching. Options include +:memory_store+, +:file_store+, +:mem_cache_store+ or the name of your own custom class. +* +config.cache_store+ configures which cache store to use for Rails caching. Options include +:memory_store+, +:file_store+, +:mem_cache_store+ or the name of your own custom class. Defaults to +:file_store+. * +config.colorize_logging+ specifies whether or not to use ANSI color codes when logging information. Defaults to _true_. -- cgit v1.2.3 From 1304c92b68ef365fd4863de0a9fd5ce38b71b67c Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Fri, 3 Dec 2010 13:05:58 +1100 Subject: Config guide: Mention ActionDispatch::Callbacks methods: before, to_prepare and after --- railties/guides/source/configuring.textile | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index 7475575e31..89c6686690 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -260,6 +260,10 @@ h4. Configuring Action Dispatch * +config.action_dispatch.session_store+ sets the name of the store for session data. The default is +:cookie_store+; other valid options include +:active_record_store+, +:mem_cache_store+ or the name of your own custom class. +* +ActionDispatch::Callbacks.before+ takes a block of code to run before the request. +* +ActionDispatch::Callbacks.to_prepare+ takes a block to run after +ActionDispatch::Callbacks.before+, but before the request. Runs for every request in +development+ mode, but only once for +production+ or environments with +cache_classes+ set to +true+. +* +ActionDispatch::Callbacks.after+ takes a block of code to run after the request. + h4. Configuring Action View There are only a few configuration options for Action View, starting with four on +ActionView::Base+: -- cgit v1.2.3 From 79b14407ad044133587ccb2d7fbc89b2e78e5da4 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Fri, 3 Dec 2010 17:26:40 +1100 Subject: Config guide: add tld_length to ActionDispatch section --- railties/guides/source/configuring.textile | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index 89c6686690..ac1c6e5cc0 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -261,9 +261,13 @@ h4. Configuring Action Dispatch * +config.action_dispatch.session_store+ sets the name of the store for session data. The default is +:cookie_store+; other valid options include +:active_record_store+, +:mem_cache_store+ or the name of your own custom class. * +ActionDispatch::Callbacks.before+ takes a block of code to run before the request. + * +ActionDispatch::Callbacks.to_prepare+ takes a block to run after +ActionDispatch::Callbacks.before+, but before the request. Runs for every request in +development+ mode, but only once for +production+ or environments with +cache_classes+ set to +true+. + * +ActionDispatch::Callbacks.after+ takes a block of code to run after the request. +* +ActionDispatch::Http::URL.tld_length+ sets the TLD (top-level domain) length for the application. Defaults to +1+. + h4. Configuring Action View There are only a few configuration options for Action View, starting with four on +ActionView::Base+: -- cgit v1.2.3 From e600f8420821f1356553e908155be7a153c43391 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Fri, 3 Dec 2010 17:28:51 +1100 Subject: Config guide: Add cache_asset_ids --- railties/guides/source/configuring.textile | 2 ++ 1 file changed, 2 insertions(+) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index ac1c6e5cc0..b761a4f826 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -282,6 +282,8 @@ There are only a few configuration options for Action View, starting with four o * +config.action_view.erb_trim_mode+ gives the trim mode to be used by ERB. It defaults to +'-'+. See the "ERB documentation":http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/ for more information. +* +ActionView::Helpers::AssetTagHelper::AssetPaths.cache_asset_ids+ With the cache enabled, the asset tag helper methods will make fewer expensive file system calls (the default implementation checks the file system timestamp). However this prevents you from modifying any asset files while the server is running. + h4. Configuring Action Mailer There are a number of settings available on +config.action_mailer+: -- cgit v1.2.3 From 04779fbadd4e77887a8899585f01141cfc27babc Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Fri, 3 Dec 2010 17:34:34 +1100 Subject: Config guide: should use config.action_dispatch.tld_length to set the TLD --- railties/guides/source/configuring.textile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index b761a4f826..83789ab710 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -260,14 +260,14 @@ h4. Configuring Action Dispatch * +config.action_dispatch.session_store+ sets the name of the store for session data. The default is +:cookie_store+; other valid options include +:active_record_store+, +:mem_cache_store+ or the name of your own custom class. +* +config.action_dispatch.tld_length+ sets the TLD (top-level domain) length for the application. Defaults to +1+. + * +ActionDispatch::Callbacks.before+ takes a block of code to run before the request. * +ActionDispatch::Callbacks.to_prepare+ takes a block to run after +ActionDispatch::Callbacks.before+, but before the request. Runs for every request in +development+ mode, but only once for +production+ or environments with +cache_classes+ set to +true+. * +ActionDispatch::Callbacks.after+ takes a block of code to run after the request. -* +ActionDispatch::Http::URL.tld_length+ sets the TLD (top-level domain) length for the application. Defaults to +1+. - h4. Configuring Action View There are only a few configuration options for Action View, starting with four on +ActionView::Base+: -- cgit v1.2.3 From b800125ae8a9ab1a1b4d773f21b4275a36fb0351 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Fri, 3 Dec 2010 18:06:02 +1100 Subject: Config guide: Add javascript_expansions and stylesheet_expansions --- railties/guides/source/configuring.textile | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index 83789ab710..837b3b563c 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -282,6 +282,30 @@ There are only a few configuration options for Action View, starting with four o * +config.action_view.erb_trim_mode+ gives the trim mode to be used by ERB. It defaults to +'-'+. See the "ERB documentation":http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/ for more information. +* +config.action_view.javascript_expansions+ a hash containining expansions that can be used for javascript include tag. By default, this is defined as: + + + config.action_view.javascript_expansions = { :defaults => ['prototype', 'effects', 'dragdrop', 'controls', 'rails'] } + + +However, you may add to this by defining others: + + + config.action_view.javascript_expansions[:jquery] = ["jquery", "jquery-ui"] + + +Then this can be referenced in the view with the following code: + + + <%= javascript_include_tag :jquery %> + + +* +config.action_view.stylesheet_expansions+ works in much the same way as +javascript_expansions+, but has no default key. Keys defined for this hash can be referenced in the view like such: + + + <%= stylesheet_link_tag :special %> + + * +ActionView::Helpers::AssetTagHelper::AssetPaths.cache_asset_ids+ With the cache enabled, the asset tag helper methods will make fewer expensive file system calls (the default implementation checks the file system timestamp). However this prevents you from modifying any asset files while the server is running. h4. Configuring Action Mailer -- cgit v1.2.3 From 30bcdff4057374f8ca864bbbbc3f25e35b269801 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Fri, 3 Dec 2010 19:16:25 +1100 Subject: Config guide: begin documenting the initializers --- railties/guides/source/configuring.textile | 105 +++++++++++++++++++++++++++-- 1 file changed, 101 insertions(+), 4 deletions(-) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index 837b3b563c..0236e72529 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -362,7 +362,6 @@ There are a few configuration options available in Active Support: * +ActiveSupport::Logger.silencer+ is set to +false+ to disable the ability to silence logging in a block. The default is +true+. - h3. Rails Environment Settings Some parts of Rails can also be configured externally by supplying environment variables. The following environment variables are recognized by various parts of Rails: @@ -380,7 +379,7 @@ h3. Initialization events Rails has 5 initialization events which can be hooked into (listed in order that they are ran): * +before_configuration+: This is run as soon as the application constant inherits from +Rails::Application+. The +config+ calls are evaluated before this happens. -* +before_initialize+: This is run directly before the initialization process of the application occurs. +* +before_initialize+: This is run directly before the initialization process of the application occurs with the +:bootstrap_hook+ initializer near the beginning of the Rails initialization process. * +to_prepare+: Run after the initializers are ran for all Railties (including the application itself), but before eager loading and the middleware stack is built. * +before_eager_load+: This is run directly before eager loading occurs, which is the default behaviour for the _production_ environment and not for the +development+ enviroment. * +after_initialize+: Run directly after the initialization of the application, but before the application initializers are run. @@ -398,7 +397,6 @@ Rails has several initializers that run on startup that are all defined by using end - The +initializer+ method takes three arguments with the first being the name for the initializer and the second being an options hash (not shown here) and the third being a block. The +:before+ key in the options hash can be specified to specify which initializer this new initializer must run before, and the +:after+ key will specify which initializer to run this initializer _after_. Initializers defined using the +initializer+ method will be ran in the order they are defined in, with the exception of ones that use the +:before+ or +:after+ methods. @@ -407,6 +405,104 @@ WARNING: You may put your initializer before or after any other initializer in t The block's argument of the +initialize+ is the instance of the application itself, and so we can access the configuration on it by using the +config+ method as this initializer does. +Because +Rails::Application+ inherits from +Rails::Railtie+ (indirectly), you can use the +initializer+ method in +config/application.rb+ to define initializers for the application. + +Below is a comprehensive list of all the initializers found in Rails in the order that they are defined (and therefore run in, unless otherwise stated). + +h4. +load_environment_hook+ + +Serves as a placeholder so that +:load_environment_config+ can be defined to run before it. + +h4. +load_active_support+ + +Requires +active_support/dependencies+ which sets up the basis for Active Support. Optionally requires +active_support/all+ if +config.active_support.bare+ is un-truthful, which is the default. + +h4. +preload_frameworks+ + +Will load all autoload dependencies of Rails automatically if +config.preload_frameworks+ is +true+ or "truthful". By default this configuration option is disabled. In Rails, when internal classes are referenced for the first time they are autoloaded. +:preload_frameworks+ loads all of this at once on initialization. + +h4. +initialize_logger+ + +Initializes the logger (an +ActiveSupport::BufferedLogger+ object) for the application and makes it accessible at +Rails.logger+, providing that there's no initializer inserted before this point that has defined +Rails.logger+. + +h4. +initialize_cache+ + +If +RAILS_CACHE+ isn't yet set, initializes the cache by referencing the value in +config.cache_store+ and stores the outcome as +RAILS_CACHE+. If this object responds to the +middleware+ method, its middleware is inserted before +Rack::Runtime+ in the middleware stack. + +h4. +set_clear_dependencies_hook+ + +Provides a hook for +active_record.set_dispatch_hooks+ to use, which will run before this initializer. + +This initializer -- which runs only if +cache_classes+ is set to +false+ -- uses +ActionDispatch::Callbacks.after+ to remove the constants which have been referenced during the request from the object space so that they will be reloaded during the following request. + +h4. +initialize_dependency_mechanism+ + +If +config.cache_classes+ is set to +true+, configures +ActiveSupport::Dependencies.mechanism+ to +require+ dependencies rather than +load+ them. + +h4. +bootstrap_hook+ + +Runs all configured +before_initialize+ blocks. + +h4. +i18n.callbacks+ + +In the development environment, sets up a +to_prepare+ callback which will call +I18n.reload!+ if any of the locales have changed since the last request. In production mode this callback will only run on the first request. + +h4. +active_support.initialize_whiny_nils+ + +Will require +active_support/whiny_nil+ if +config.whiny_nil+ is set to +true+. This file will output errors such as: + + + Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id + + +And: + + + You have a nil object when you didn't expect it! + You might have expected an instance of Array. + The error occurred while evaluating nil.each + + +h4. +active_support.deprecation_behavior+ + +Sets up deprecation reporting for environments, defaulting to +log+ for development, +notify+ for production and +stderr+ for test. If a value isn't set for +config.active_support.deprecation+ then this initializer will prompt the user to configure this line in the current environment's +config/environments+ file. + +h4. +active_support.initialize_time_zone+ + +Sets the default time zone for the application based off the +config.time_zone+ setting, which defaults to "UTC". + +h4. +action_dispatch.configure+ + +Configures the +ActionDispatch::Http::URL.tld_length+ to be set to the value of +config.action_dispatch.tld_length+. + +h4. +action_view.cache_asset_ids+ + +Will set +ActionView::Helpers::AssetTagHelper::AssetPaths.cache_asset_ids+ to +false+ when Active Support loads, but only if +config.cache_classes+ is too. + +h4. +action_view.javascript_expansions+ + +Registers the expansions set up by +config.action_view.javascript_expansions+ and +config.action_view.stylesheet_expansions+ to be recognised by Action View and therefore usable in the views. + +h4. +action_view.set_configs+ + +Sets up Action View by using the settings in +config.action_view+ by +send+'ing the method names as setters to +ActionView::Base+ and passing the values through. + +h4. +action_controller.logger+ + +Sets +ActionController::Base.logger+ -- if it's not already set -- to +Rails.logger+. + +h4. +action_controller.initialize_framework_caches+ + +Sets +ActionController::Base.cache_store+ -- if it's not already set -- to +RAILS_CACHE+. + +h4. +action_controller.set_configs+ + +Sets up Action View by using the settings in +config.action_controller+ by +send+'ing the method names as setters to +ActionController::Base+ and passing the values through. + +h4 +active_record.initialize_timezone+ + +Sets +ActiveRecord::Base.time_zone_aware_attributes+ to true, as well as setting +ActiveRecord::Base.default_timezone+ to UTC. + h4. Initializer files After loading the framework and any gems and plugins in your application, Rails turns to loading initialization code from +config/initializers+. The files in this directory can be used to hold configuration settings that should be made after all of the frameworks and plugins are loaded. @@ -417,7 +513,8 @@ TIP: If you have any ordering dependency in your initializers, you can control t h3. Changelog -* November 26, 2010: Removed all config settings not available in Rails 3 (Ryan Bigg) +* December 3, 2010: Added initialization events for Rails 3 ("Ryan Bigg":http://ryanbigg.com) +* November 26, 2010: Removed all config settings not available in Rails 3 ("Ryan Bigg":http://ryanbigg.com) * August 13, 2009: Updated with config syntax and added general configuration options by "John Pignata" * January 3, 2009: First reasonably complete draft by "Mike Gunderloy":credits.html#mgunderloy * November 5, 2008: Rough outline by "Mike Gunderloy":credits.html#mgunderloy -- cgit v1.2.3 From c4669d3c027e5d9252ecfbf3a9792fbdb4d878d0 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Sat, 4 Dec 2010 11:27:17 +1100 Subject: Config guide: continuing work on documenting the initializers --- railties/guides/source/configuring.textile | 70 ++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 3 deletions(-) (limited to 'railties/guides/source/configuring.textile') diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index 0236e72529..afafabd1e9 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -497,11 +497,75 @@ Sets +ActionController::Base.cache_store+ -- if it's not already set -- to +RAI h4. +action_controller.set_configs+ -Sets up Action View by using the settings in +config.action_controller+ by +send+'ing the method names as setters to +ActionController::Base+ and passing the values through. +Sets up Action Controller by using the settings in +config.action_controller+ by +send+'ing the method names as setters to +ActionController::Base+ and passing the values through. + +h4. +action_controller.compile_config_methods+ + +Initializes methods for the config settings specified so that they are quicker to access. + +h4. +active_record.initialize_timezone+ + +Sets +ActiveRecord::Base.time_zone_aware_attributes+ to true, as well as setting +ActiveRecord::Base.default_timezone+ to UTC. When attributes are read from the database, they will be converted into the time zone specified by +Time.zone+. + +h4. +active_record.logger+ + +Sets +ActiveRecord::Base.logger+ -- if it's not already set -- to +Rails.logger+. + +h4. +active_record.set_configs+ + +Sets up Active Record by using the settings in +config.active_record+ by +send+'ing the method names as setters to +ActiveRecord::Base+ and passing the values through. + +h4. +active_record.initialize_database+ + +Loads the database configuration (by default) from +config/database.yml+ and establishes a connection for the current environment. + +h4. +active_record.log_runtime+ + +Includes +ActiveRecord::Railties::ControllerRuntime+ which is responsible for reporting the length of time Active Record calls took for the request back to the logger. + +h4. +active_record.set_dispatch_hooks+ + +If +config.cache_classes+ is set to false, all reloadable connections to the database will be reset. + +h4. +action_mailer.logger+ + +Sets +ActionMailer::Base.logger+ -- if it's not already set -- to +Rails.logger+. + +h4. +action_mailer.set_configs+ + +Sets up Action Mailer by using the settings in +config.action_mailer+ by +send+'ing the method names as setters to +ActionMailer::Base+ and passing the values through. + +h4. +action_mailer.compile_config_methods+ + +Initializes methods for the config settings specified so that they are quicker to access. + +h4. +active_resource.set_configs+ + +Sets up Active Resource by using the settings in +config.active_resource+ by +send+'ing the method names as setters to +ActiveResource::Base+ and passing the values through. + +h4. +set_load_path+ + +This initializer runs before +bootstrap_hook+. Adds the +vendor+, +lib+, all directories of +app+ and any paths specified by +config.load_paths+ to +$LOAD_PATH+. + +h4. +set_autoload_path+ + +This initializer runs before +bootstrap_hook+. Adds all sub-directories of +app+ and paths specified by +config.autoload_paths+ to +ActiveSupport::Dependencies.autoload_paths+. + +h4. +add_routing_paths+ + +Loads (by default) all +config/routes.rb+ files (in the application and railties, including engines) and sets up the routes for the application. + +h4. +add_locales+ + +Adds the files in +config/locales+ (from the application, railties and engines) to +I18n.load_path+, making available the translations in these files. + +h4. +add_view_paths+ + +Adds the directory +app/views+ from the application, railties and engines to the lookup path for view files for the application. + +h4. +load_environment_config+ -h4 +active_record.initialize_timezone+ -Sets +ActiveRecord::Base.time_zone_aware_attributes+ to true, as well as setting +ActiveRecord::Base.default_timezone+ to UTC. h4. Initializer files -- cgit v1.2.3