From 5a898e106a6f92ad2773a6525b0899cf906d2b3f Mon Sep 17 00:00:00 2001 From: Peter Baker Date: Thu, 14 Oct 2010 11:24:25 -0500 Subject: Explain actionamailer authentication types --- actionmailer/lib/action_mailer/base.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index 0bf60a2c24..478ceda389 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -290,7 +290,9 @@ module ActionMailer #:nodoc: # * :password - If your mail server requires authentication, set the password in this setting. # * :authentication - If your mail server requires authentication, you need to specify the # authentication type here. - # This is a symbol and one of :plain, :login, :cram_md5. + # This is a symbol and one of :plain (will send the password in the clear), :login (will + # send password BASE64 encoded) or :cram_md5 (combines a Challenge/Response mechanism to exchange + # information and a cryptographic Message Digest 5 algorithm to hash important information) # * :enable_starttls_auto - When set to true, detects if STARTTLS is enabled in your SMTP server # and starts to use it. # -- cgit v1.2.3 From 1ef9ddde90a6a10099faecc93542335c437cfb09 Mon Sep 17 00:00:00 2001 From: Jared Crapo Date: Thu, 21 Oct 2010 11:56:36 -0700 Subject: Fixed typo in code for Session Expiry --- railties/guides/source/security.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/railties/guides/source/security.textile b/railties/guides/source/security.textile index 4656cf4e40..e2103959ac 100644 --- a/railties/guides/source/security.textile +++ b/railties/guides/source/security.textile @@ -166,7 +166,7 @@ end The section about session fixation introduced the problem of maintained sessions. An attacker maintaining a session every five minutes can keep the session alive forever, although you are expiring sessions. A simple solution for this would be to add a created_at column to the sessions table. Now you can delete sessions that were created a long time ago. Use this line in the sweep method above: -delete_all "updated_at < '#{time.to_s(:db)}' OR +delete_all "updated_at < '#{time.ago.to_s(:db)}' OR created_at < '#{2.days.ago.to_s(:db)}'" -- cgit v1.2.3 From 5b502ed9ccc3fef7ba956588119e0e5b257dfd66 Mon Sep 17 00:00:00 2001 From: Greg Jastrab Date: Fri, 22 Oct 2010 13:30:00 -0400 Subject: fixed example code for i18n exception handling --- railties/guides/source/i18n.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/railties/guides/source/i18n.textile b/railties/guides/source/i18n.textile index 8a7e9fcae6..998eac81f6 100644 --- a/railties/guides/source/i18n.textile +++ b/railties/guides/source/i18n.textile @@ -830,7 +830,7 @@ In other contexts you might want to change this behaviour, though. E.g. the defa module I18n - def just_raise_that_exception(*args) + def self.just_raise_that_exception(*args) raise args.first end end -- cgit v1.2.3 From 67c40160d384037d664952cee808a49104bdc627 Mon Sep 17 00:00:00 2001 From: "Ryan L. Cross" Date: Sun, 24 Oct 2010 19:17:49 -0700 Subject: Corrected typo and wording. --- activesupport/lib/active_support/cache.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb index 9098ffbfec..9771ca966f 100644 --- a/activesupport/lib/active_support/cache.rb +++ b/activesupport/lib/active_support/cache.rb @@ -214,7 +214,7 @@ module ActiveSupport # cache.write(key, value, :expire_in => 1.minute) # Set a lower value for one entry # # Setting :race_condition_ttl is very useful in situations where a cache entry - # is used very frequently unver heavy load. If a cache expires and due to heavy load + # is used very frequently and is under heavy load. If a cache expires and due to heavy load # seven different processes will try to read data natively and then they all will try to # write to cache. To avoid that case the first process to find an expired cache entry will # bump the cache expiration time by the value set in :race_condition_ttl. Yes -- cgit v1.2.3 From f28916194cc19759dd6b1ce4f22ef59b49f0c8f8 Mon Sep 17 00:00:00 2001 From: Aditya Sanghi Date: Sat, 27 Nov 2010 15:20:46 +0530 Subject: Resolves LH #6063, should be :expires_in not :expire_in --- activesupport/lib/active_support/cache.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb index 9098ffbfec..d31dad6bc7 100644 --- a/activesupport/lib/active_support/cache.rb +++ b/activesupport/lib/active_support/cache.rb @@ -210,8 +210,8 @@ module ActiveSupport # be specified as an option to the construction in which call all entries will be # affected. Or it can be supplied to the +fetch+ or +write+ method for just one entry. # - # cache = ActiveSupport::Cache::MemoryStore.new(:expire_in => 5.minutes) - # cache.write(key, value, :expire_in => 1.minute) # Set a lower value for one entry + # cache = ActiveSupport::Cache::MemoryStore.new(:expires_in => 5.minutes) + # cache.write(key, value, :expires_in => 1.minute) # Set a lower value for one entry # # Setting :race_condition_ttl is very useful in situations where a cache entry # is used very frequently unver heavy load. If a cache expires and due to heavy load -- cgit v1.2.3 From 04922bafda9456ca9b6b8c59f231c402cb7952b7 Mon Sep 17 00:00:00 2001 From: Aditya Sanghi Date: Sat, 27 Nov 2010 19:56:08 +0530 Subject: grammar fix --- activemodel/lib/active_model/attribute_methods.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/activemodel/lib/active_model/attribute_methods.rb b/activemodel/lib/active_model/attribute_methods.rb index c1c5640616..fc5f5c4c66 100644 --- a/activemodel/lib/active_model/attribute_methods.rb +++ b/activemodel/lib/active_model/attribute_methods.rb @@ -46,8 +46,8 @@ module ActiveModel # end # end # - # Notice that whenever you include ActiveModel::AttributeMethods in your class, - # it requires you to implement a attributes methods which returns a hash + # Note that whenever you include ActiveModel::AttributeMethods in your class, + # it requires you to implement an attributes method which returns a hash # with each attribute name in your model as hash key and the attribute value as # hash value. # -- cgit v1.2.3 From 1662aa1a15ad3f2218f85e4bd58aea56708a87a1 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Thu, 11 Nov 2010 05:27:40 +0900 Subject: Added a space before "do" keyword --- actionpack/lib/action_view/helpers/form_tag_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index 92645f5cf9..50f065f03d 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -39,7 +39,7 @@ module ActionView # form_tag('/upload', :multipart => true) # # =>
# - # <%= form_tag('/posts')do -%> + # <%= form_tag('/posts') do -%> #
<%= submit_tag 'Save' %>
# <% end -%> # # =>
-- cgit v1.2.3 From 2029187c5611e2da9995637d4f738ed3af834172 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Sun, 28 Nov 2010 09:41:49 +0900 Subject: s/myqsl/mysql/ --- railties/guides/source/contributing_to_rails.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/railties/guides/source/contributing_to_rails.textile b/railties/guides/source/contributing_to_rails.textile index ccb9db5eee..1a1f4e9858 100644 --- a/railties/guides/source/contributing_to_rails.textile +++ b/railties/guides/source/contributing_to_rails.textile @@ -132,7 +132,7 @@ You can now run tests as you did for +sqlite3+: rake test_mysql -You can also replace +myqsl+ with +postgresql+, +jdbcmysql+, +jdbcsqlite3+ or +jdbcpostgresql+. Check out the file +activerecord/RUNNING_UNIT_TESTS+ for information on running more targeted database tests, or the file +ci/ci_build.rb+ to see the test suite that the Rails continuous integration server runs. +You can also replace +mysql+ with +postgresql+, +jdbcmysql+, +jdbcsqlite3+ or +jdbcpostgresql+. Check out the file +activerecord/RUNNING_UNIT_TESTS+ for information on running more targeted database tests, or the file +ci/ci_build.rb+ to see the test suite that the Rails continuous integration server runs. NOTE: If you're working with Active Record code, you _must_ ensure that the tests pass for at least MySQL, PostgreSQL, and SQLite 3. Subtle differences between the various Active Record database adapters have been behind the rejection of many patches that looked OK when tested only against MySQL. -- cgit v1.2.3 From 9bd291407c70daac1b2777f552f599a6fff9f387 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Sat, 27 Nov 2010 22:16:51 -0500 Subject: make it clear that recompilation happens only in development mode --- actionpack/lib/action_view/base.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index 1beae37af3..15944138f7 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -76,8 +76,8 @@ module ActionView #:nodoc: # # === Template caching # - # By default, Rails will compile each template to a method in order to render it. When you alter a template, Rails will - # check the file's modification time and recompile it. + # By default, Rails will compile each template to a method in order to render it. When you alter a template, + # Rails will check the file's modification time and recompile it in development mode. # # == Builder # -- cgit v1.2.3 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(+) 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(+) 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(-) 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(-) 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(-) 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(-) 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(-) 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(+) 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(-) 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(+) 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(+) 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(+) 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(-) 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(-) 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(-) 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 964c2025ff7b4d22902ed8ee86c3e2858a4cf3ba Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Mon, 29 Nov 2010 15:08:35 +1100 Subject: Use ARel for Range Conditions section, remove Date & Time section because users should *never* do that. --- .../guides/source/active_record_querying.textile | 60 +++------------------- 1 file changed, 7 insertions(+), 53 deletions(-) diff --git a/railties/guides/source/active_record_querying.textile b/railties/guides/source/active_record_querying.textile index 328439fdb8..0447013e24 100644 --- a/railties/guides/source/active_record_querying.textile +++ b/railties/guides/source/active_record_querying.textile @@ -65,6 +65,7 @@ The methods are: * +lock+ * +readonly+ * +from+ +* +having+ All of the above methods return an instance of ActiveRecord::Relation. @@ -103,7 +104,7 @@ h5. +first+ client = Client.first -=> # "Lifo"> +=> # SQL equivalent of the above is: @@ -120,7 +121,7 @@ h5. +last+ client = Client.last -=> # "Russel"> +=> # SQL equivalent of the above is: @@ -231,7 +232,7 @@ WARNING: Building your own conditions as pure strings can leave you vulnerable t h4. Array Conditions -Now what if that number could vary, say as an argument from somewhere, or perhaps from the user's level status somewhere? The find then becomes something like: +Now what if that number could vary, say as an argument from somewhere? The find then becomes something like: Client.where("orders_count = ?", params[:orders]) @@ -279,62 +280,15 @@ h5(#array-range_conditions). Range Conditions If you're looking for a range inside of a table (for example, users created in a certain timeframe) you can use the conditions option coupled with the +IN+ SQL statement for this. If you had two dates coming in from a controller you could do something like this to look for a range: -Client.where("created_at IN (?)", - (params[:start_date].to_date)..(params[:end_date].to_date)) +Client.where(:created_at => (params[:start_date].to_date)..(params[:end_date].to_date)) -This would generate the proper query which is great for small ranges but not so good for larger ranges. For example if you pass in a range of date objects spanning a year that's 365 (or possibly 366, depending on the year) strings it will attempt to match your field against. +This query will generate something similar to the following SQL: -SELECT * FROM users WHERE (created_at IN - ('2007-12-31','2008-01-01','2008-01-02','2008-01-03','2008-01-04','2008-01-05', - '2008-01-06','2008-01-07','2008-01-08','2008-01-09','2008-01-10','2008-01-11', - '2008-01-12','2008-01-13','2008-01-14','2008-01-15','2008-01-16','2008-01-17', - '2008-01-18','2008-01-19','2008-01-20','2008-01-21','2008-01-22','2008-01-23',... - ‘2008-12-15','2008-12-16','2008-12-17','2008-12-18','2008-12-19','2008-12-20', - '2008-12-21','2008-12-22','2008-12-23','2008-12-24','2008-12-25','2008-12-26', - '2008-12-27','2008-12-28','2008-12-29','2008-12-30','2008-12-31')) + SELECT "clients".* FROM "clients" WHERE ("clients"."created_at" BETWEEN '2010-09-29' AND '2010-11-30') -h5. Time and Date Conditions - -Things can get *really* messy if you pass in Time objects as it will attempt to compare your field to *every second* in that range: - - -Client.where("created_at IN (?)", - (params[:start_date].to_date.to_time)..(params[:end_date].to_date.to_time)) - - - -SELECT * FROM users WHERE (created_at IN - ('2007-12-01 00:00:00', '2007-12-01 00:00:01' ... - '2007-12-01 23:59:59', '2007-12-02 00:00:00')) - - -This could possibly cause your database server to raise an unexpected error, for example MySQL will throw back this error: - - -Got a packet bigger than 'max_allowed_packet' bytes: _query_ - - -Where _query_ is the actual query used to get that error. - -In this example it would be better to use greater-than and less-than operators in SQL, like so: - - -Client.where( - "created_at > ? AND created_at < ?", params[:start_date], params[:end_date]) - - -You can also use the greater-than-or-equal-to and less-than-or-equal-to like this: - - -Client.where( - "created_at >= ? AND created_at <= ?", params[:start_date], params[:end_date]) - - -Just like in Ruby. If you want a shorter syntax be sure to check out the "Hash Conditions":#hash-conditions section later on in the guide. - h4. Hash Conditions Active Record also allows you to pass in hash conditions which can increase the readability of your conditions syntax. With hash conditions, you pass in a hash with keys of the fields you want conditionalised and the values of how you want to conditionalise them: -- cgit v1.2.3 From 9e655e8571345701b23a8cdd4d480ecf3a1623d3 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Mon, 29 Nov 2010 15:12:39 +1100 Subject: Bring order description in line with actual text. --- railties/guides/source/active_record_querying.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/railties/guides/source/active_record_querying.textile b/railties/guides/source/active_record_querying.textile index 0447013e24..e41b5fb606 100644 --- a/railties/guides/source/active_record_querying.textile +++ b/railties/guides/source/active_record_querying.textile @@ -339,7 +339,7 @@ SELECT * FROM clients WHERE (clients.orders_count IN (1,3,5)) h4. Ordering -To retrieve records from the database in a specific order, you can specify the +:order+ option to the +find+ call. +To retrieve records from the database in a specific order, you can use the +order+ method. For example, if you're getting a set of records and want to order them in ascending order by the +created_at+ field in your table: -- 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(-) 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(+) 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(+) 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 aa9a3227a0151af87e1eb5a6c4b7b0b095fc33c9 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Mon, 29 Nov 2010 21:38:37 -0500 Subject: Rewording existing comment --- actionpack/lib/abstract_controller/layouts.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/actionpack/lib/abstract_controller/layouts.rb b/actionpack/lib/abstract_controller/layouts.rb index b68c7d9216..606f7eedec 100644 --- a/actionpack/lib/abstract_controller/layouts.rb +++ b/actionpack/lib/abstract_controller/layouts.rb @@ -235,13 +235,10 @@ module AbstractController controller_path end - # Takes the specified layout and creates a _layout method to be called - # by _default_layout + # Creates a _layout method to be called by _default_layout . # - # If there is no explicit layout specified: - # If a layout is found in the view paths with the controller's - # name, return that string. Otherwise, use the superclass' - # layout (which might also be implied) + # If a layout is not explicitly mentioned then look for a layout with the controller's name. + # if nothing is found then try same procedure to find super class's layout. def _write_layout_method remove_possible_method(:_layout) -- cgit v1.2.3 From aa1ac1ca8cf9557dae72604a48de1f0e58515b40 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Tue, 30 Nov 2010 09:44:12 -0500 Subject: Add comment for config_accessor method --- activesupport/lib/active_support/configurable.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/activesupport/lib/active_support/configurable.rb b/activesupport/lib/active_support/configurable.rb index 58ed37b018..644db0b205 100644 --- a/activesupport/lib/active_support/configurable.rb +++ b/activesupport/lib/active_support/configurable.rb @@ -38,6 +38,18 @@ module ActiveSupport yield config end + # Allows you to add shortcut so that you don't have to refer to attribute through config. + # Also look at the example for config to contrast. + # + # class User + # include ActiveSupport::Configurable + # config_accessor :allowed_access + # end + # + # user = User.new + # user.allowed_access = true + # user.allowed_access # => true + # def config_accessor(*names) names.each do |name| code, line = <<-RUBY, __LINE__ + 1 -- cgit v1.2.3 From 3c7a33c0510e30a3017b007d8ed8afcae02ef4a6 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Tue, 30 Nov 2010 10:00:47 -0500 Subject: Rewording existing comment --- actionpack/lib/abstract_controller/base.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/actionpack/lib/abstract_controller/base.rb b/actionpack/lib/abstract_controller/base.rb index f83eaded88..c384fd0978 100644 --- a/actionpack/lib/abstract_controller/base.rb +++ b/actionpack/lib/abstract_controller/base.rb @@ -31,10 +31,9 @@ module AbstractController # A list of all internal methods for a controller. This finds the first # abstract superclass of a controller, and gets a list of all public # instance methods on that abstract class. Public instance methods of - # a controller would normally be considered action methods, so we - # are removing those methods on classes declared as abstract - # (ActionController::Metal and ActionController::Base are defined - # as abstract) + # a controller would normally be considered action methods, so methods + # declared on abstract classes are being removed. + # (ActionController::Metal and ActionController::Base are defined as abstract) def internal_methods controller = self controller = controller.superclass until controller.abstract? -- cgit v1.2.3 From b640e3f5107b68e62967cba20e5f627170d98460 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Wed, 1 Dec 2010 13:48:33 +1100 Subject: Mention that the documentation of create_file can be found on rdoc.info ino the generators guide --- railties/guides/source/generators.textile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/railties/guides/source/generators.textile b/railties/guides/source/generators.textile index 99c34ed30f..909c79f3cb 100644 --- a/railties/guides/source/generators.textile +++ b/railties/guides/source/generators.textile @@ -45,6 +45,8 @@ class InitializerGenerator < Rails::Generators::Base end +NOTE: +create_file+ is a method provided by +Thor::Actions+ and the documentation for it and its brethren can be found at "rdoc.info":http://rdoc.info/github/wycats/thor/master/Thor/Actions. + Our new generator is quite simple: it inherits from +Rails::Generators::Base+ and has one method definition. Each public method in the generator is executed when a generator is invoked. Finally, we invoke the +create_file+ method that will create a file at the given destination with the given content. If you are familiar with the Rails Application Templates API, you'll feel right at home with the new generators API. To invoke our new generator, we just need to do: -- cgit v1.2.3 From 04ec2c6d6c9fe92655bb171521f2167d28fd66fb Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Wed, 1 Dec 2010 15:22:42 +1100 Subject: Begin covering application templates in the generators guide --- railties/guides/source/generators.textile | 42 ++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/railties/guides/source/generators.textile b/railties/guides/source/generators.textile index 909c79f3cb..ea45f7c31c 100644 --- a/railties/guides/source/generators.textile +++ b/railties/guides/source/generators.textile @@ -1,4 +1,4 @@ -h2. Creating and Customizing Rails Generators +h2. Creating and Customizing Rails Generators & Templates Rails generators are an essential tool if you plan to improve your workflow. With this guide you will learn how to create generators and customize existing ones. @@ -10,6 +10,7 @@ In this guide you will: * Customize your scaffold by creating new generators * Customize your scaffold by changing generator templates * Learn how to use fallbacks to avoid overwriting a huge set of generators +* Learn how to create an application template endprologue. @@ -363,8 +364,47 @@ $ rails generate scaffold Comment body:text Fallbacks allow your generators to have a single responsibility, increasing code reuse and reducing the amount of duplication. +h3. Application templates + +Now that you've seen how generators can be used _inside_ an application, did you know they can also be used to _generate_ applications too? This kind of generator is referred as a "template". + + + gem("rspec-rails", :group => "test") + gem("cucumber-rails", :group => "test") + + if yes?("Would you like to install Devise?") + gem("devise") + generate("devise:install") + model_name = ask("What would you like the user model to be called? [user]") + model_name = "user" if model_name.blank? + generate("devise", model_name) + end + + +In the above template we specify that the application relies on the +rspec-rails+ and +cucumber-rails+ gem so these two will be added to the +test+ group in the +Gemfile+. Then we pose a question to the user about whether or not they would like to install Devise. If the user replies "y" or "yes" to this question, then the template will add Devise to the +Gemfile+ outside of any group and then runs the +devise:install+ generator. This template then takes the users input and runs the +devise+ generator, with the user's answer from the last question being passed to this generator. + +Imagine that this template was in a file called +template.rb+. We can use it to modify the outcome of the +rails new+ command by using the +-m+ option and passing in the filename: + + + rails new thud -m template.rb + + +This command will generate the +Thud+ application, and then apply the template to the generated output. + +Templates don't have to be stored on the local system, the +-m+ option also supports online templates: + + + rails new thud -m https://gist.github.com/722911 + + +Whilst the remainder of this guide doesn't cover how to generate the most awesome template known to man, it will take you through the methods available at your disposal so that you can develop it yourself. + + + h3. Changelog +* December 1, 2010: Addition of Rails application templates by "Ryan Bigg" + * August 23, 2010: Edit pass by "Xavier Noria":credits.html#fxn * April 30, 2010: Reviewed by José Valim -- cgit v1.2.3 From f3bf63d6111e9b305819cb9d19720971b3b91e6d Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Wed, 1 Dec 2010 15:53:36 +1100 Subject: Covering generator methods provided by Rails in the generators guide --- railties/guides/source/generators.textile | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/railties/guides/source/generators.textile b/railties/guides/source/generators.textile index ea45f7c31c..c57171f189 100644 --- a/railties/guides/source/generators.textile +++ b/railties/guides/source/generators.textile @@ -134,6 +134,8 @@ $ rails generate initializer core_extensions We can see that now a initializer named core_extensions was created at +config/initializers/core_extensions.rb+ with the contents of our template. That means that +copy_file+ copied a file in our source root to the destination path we gave. The method +file_name+ is automatically created when we inherit from +Rails::Generators::NamedBase+. +The methods that are available for generators are covered in the "final section":#generator_methods of this guide. + h3. Generators Lookup When you run +rails generate initializer core_extensions+ Rails requires these files in turn until one is found: @@ -397,13 +399,35 @@ Templates don't have to be stored on the local system, the +-m+ option also supp rails new thud -m https://gist.github.com/722911 -Whilst the remainder of this guide doesn't cover how to generate the most awesome template known to man, it will take you through the methods available at your disposal so that you can develop it yourself. +Whilst the final section of this guide doesn't cover how to generate the most awesome template known to man, it will take you through the methods available at your disposal so that you can develop it yourself. These same methods are also available for generators. + +h3. Generator methods + +The following are methods available for both generators and templates for Rails. + +NOTE: Methods provided by Thor are not covered this guide and can be found in "Thor's documentation":http://rdoc.info/github/wycats/thor/master/Thor/Actions.html + +h4. +plugin+ + ++plugin+ will install a plugin into the current application. + + + plugin("dynamic-form", :git => "git://github.com/rails/dynamic-form.git") + + +Available options are: +* +:git+ - Takes the path to the git repository where this plugin can be found. +* +:branch+ - The name of the branch of the git repository where the plugin is found. +* +:submodule+ - Set to +true+ for the plugin to be installed as a submodule. Defaults to +false+. +* +:svn+ - Takes the path to the svn repository where this plugin can be found. +* +:revision+ - The revision of the plugin in an SVN repository. h3. Changelog -* December 1, 2010: Addition of Rails application templates by "Ryan Bigg" +* December 1, 2010: Documenting the available methods and options for generators and templates by "Ryan Bigg":http://ryanbigg.com +* December 1, 2010: Addition of Rails application templates by "Ryan Bigg":http://ryanbigg.com * August 23, 2010: Edit pass by "Xavier Noria":credits.html#fxn -- cgit v1.2.3 From 74e178880c56bae86958e6e39be1c35532399bb3 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Wed, 1 Dec 2010 16:15:49 +1100 Subject: For templates' gem method, :env is deprecated, use :group instead --- railties/lib/rails/generators/actions.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index 378c07cb0e..d7a86a5c40 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -44,7 +44,7 @@ module Rails # # ==== Example # - # gem "rspec", :env => :test + # gem "rspec", :group => :test # gem "technoweenie-restful-authentication", :lib => "restful-authentication", :source => "http://gems.github.com/" # gem "rails", "3.0", :git => "git://github.com/rails/rails" # -- cgit v1.2.3 From 77a228785ccc6832d8e30438380aea7ad9706a70 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Wed, 1 Dec 2010 17:18:41 +1100 Subject: Add gem method documentation to the generators guide --- railties/guides/source/generators.textile | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/railties/guides/source/generators.textile b/railties/guides/source/generators.textile index c57171f189..915270ff46 100644 --- a/railties/guides/source/generators.textile +++ b/railties/guides/source/generators.textile @@ -423,6 +423,34 @@ Available options are: * +:svn+ - Takes the path to the svn repository where this plugin can be found. * +:revision+ - The revision of the plugin in an SVN repository. +h4. +gem+ + +Specifies a gem dependency of the application. + + + gem("rspec", :group => "test", :version => "2.1.0") + gem("devise", "1.1.5") + + +Available options are: + +* +:group+ - The group in the +Gemfile+ where this gem should go. +* +:version+ - The version string of the gem you want to use. Can also be specified as the second argument to the method. +* +:git+ - The URL to the git repository for this gem. + +Any additional options passed to this method are put on the end of the line: + + + gem("devise", :git => "git://github.com/plataformatec/devise", :branch => "master") + + +The above code will put the following line into +Gemfile+: + + + gem "devise", :git => "git://github.com/plataformatec/devise", :branch => "master" + + + h3. Changelog -- cgit v1.2.3 From 3a3c812c282b2972632ac7699ff7ed58de3782ec Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Wed, 1 Dec 2010 20:25:39 +1100 Subject: Finish documenting generator / template methods for the generators guide --- railties/guides/source/generators.textile | 161 ++++++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) diff --git a/railties/guides/source/generators.textile b/railties/guides/source/generators.textile index 915270ff46..a0d744333f 100644 --- a/railties/guides/source/generators.textile +++ b/railties/guides/source/generators.textile @@ -451,6 +451,167 @@ The above code will put the following line into +Gemfile+: +h4. +add_source+ + +Adds a specified source to +Gemfile+: + + + add_source "http://gems.github.com" + + +h4. +application+ + +Adds a line to +config/application.rb+ directly after the application class definition. + + + application "config.asset_host = 'http://example.com'" + + +This method can also take a block: + + + application do + "config.asset_host = 'http://example.com'" + end + end + + +Available options are: + +* +:env+ - Specify an environment for this configuration option. If you wish to use this option with the block syntax the recommended syntax is as follows: + + + application(nil, :env => "development") do + "config.asset_host = 'http://localhost:3000'" + end + + +h4. +git+ + +Runs the specified git command: + + + git :init + git :add => "." + git :commit => "-m First commit!" + git :add => "onefile.rb", :rm => "badfile.cxx" + + +The values of the hash here being the arguments or options passed to the specific git command. As per the final example shown here, multiple git commands can be specified at a time, but the order of their running is not guaranteed to be the same as the order that they were specified in. + +h4. +vendor+ + +Places a file into +vendor+ which contains the specified code. + + + vendor("sekrit.rb", '#top secret stuff') + + +This method also takes a block: + + + vendor("seeds.rb") do + "puts 'in ur app, seeding ur database'" + end + + +h4. +lib+ + +Places a file into +lib+ which contains the specified code. + + + lib("special.rb", 'p Rails.root') + + +This method also takes a block: + + + lib("super_special.rb") do + puts "Super special!" + end + + +h4. +rakefile+ + +Creates a Rake file in the +lib/tasks+ directory of the application. + + + rakefile("test.rake", 'hello there') + + +This method also takes a block: + + + rakefile("test.rake") do + %Q{ + task :rock => :environment do + puts "Rockin'" + end + } + end + + +h4. +initializer+ + +Creates an initializer in the +config/initializers+ directory of the application: + + + initializer("begin.rb", "puts 'this is the beginning'") + + +This method also takes a block: + + + initializer("begin.rb") do + puts "Almost done!" + end + + +h4. +generate+ + +Runs the specified generator where the first argument is the generator name and the remaining arguments are passed directly to the generator. + + + generate("scaffold", "forums title:string description:text") + + + +h4. +rake+ + +Runs the specified Rake task. + + + rake("db:migrate") + + +Available options are: + +* +:env+ - Specifies the environment in which to run this rake task. +* +:sudo+ - Whether or not to run this task using +sudo+. Defaults to +false+. + +h4. +capify!+ + +Runs the +capify+ command from Capistrano at the root of the application which generates Capistrano configuration. + + + capify! + + +h4. +route+ + +Adds text to the +config/routes.rb+ file: + + + route("resources :people") + + +h4. +readme+ + +Output the contents of a file in the template's +source_path+, usually a README. + + + readme("README") + h3. Changelog -- 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(-) 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 697f734455753ad23ba719539bf961c6f1bc45d2 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Thu, 2 Dec 2010 13:29:17 +1100 Subject: Associations guide: Add note that you must use the build_ prefix to build associations of the belongs_to and has_one type --- railties/guides/source/association_basics.textile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/railties/guides/source/association_basics.textile b/railties/guides/source/association_basics.textile index 14bbe907f3..2043daa4ed 100644 --- a/railties/guides/source/association_basics.textile +++ b/railties/guides/source/association_basics.textile @@ -550,6 +550,8 @@ build_customer create_customer +NOTE: When creating a new +belongs_to+ or +has_one+ association you must use the +build_+ prefix to build the association, rather than the +association.build+ method that would be used for +has_many+ or +has_and_belongs_to_many+ associations. + h6(#belongs_to-association). association(force_reload = false) The association method returns the associated object, if any. If no associated object is found, it returns +nil+. @@ -817,6 +819,8 @@ build_account create_account +NOTE: When creating a new +has_one+ or +belongs_to+ association you must use the +build_+ prefix to build the association, rather than the +association.build+ method that would be used for +has_many+ or +has_and_belongs_to_many+ associations. + h6(#has_one-association). association(force_reload = false) The association method returns the associated object, if any. If no associated object is found, it returns +nil+. -- cgit v1.2.3 From bde7d2351edf558ff5c2a3fb8d2822d5f8a2ae47 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Thu, 2 Dec 2010 13:31:11 +1100 Subject: Association guide: change wording to say that build is for initialization, create is for creating --- railties/guides/source/association_basics.textile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/railties/guides/source/association_basics.textile b/railties/guides/source/association_basics.textile index 2043daa4ed..62abc40c81 100644 --- a/railties/guides/source/association_basics.textile +++ b/railties/guides/source/association_basics.textile @@ -550,7 +550,7 @@ build_customer create_customer -NOTE: When creating a new +belongs_to+ or +has_one+ association you must use the +build_+ prefix to build the association, rather than the +association.build+ method that would be used for +has_many+ or +has_and_belongs_to_many+ associations. +NOTE: When initializing a new +has_one+ or +belongs_to+ association you must use the +build_+ prefix to build the association, rather than the +association.build+ method that would be used for +has_many+ or +has_and_belongs_to_many+ associations. To create one, use the +create_+ prefix. h6(#belongs_to-association). association(force_reload = false) @@ -819,7 +819,7 @@ build_account create_account -NOTE: When creating a new +has_one+ or +belongs_to+ association you must use the +build_+ prefix to build the association, rather than the +association.build+ method that would be used for +has_many+ or +has_and_belongs_to_many+ associations. +NOTE: When initializing a new +has_one+ or +belongs_to+ association you must use the +build_+ prefix to build the association, rather than the +association.build+ method that would be used for +has_many+ or +has_and_belongs_to_many+ associations. To create one, use the +create_+ prefix. h6(#has_one-association). association(force_reload = false) -- 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(-) 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(-) 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(-) 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(-) 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(+) 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(+) 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(-) 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(-) 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(+) 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 7f1c794a11c463f4b50d46180932fa4a62e369a5 Mon Sep 17 00:00:00 2001 From: Ryan Bigg Date: Fri, 3 Dec 2010 13:29:02 +1100 Subject: Remove extra f --- activesupport/lib/active_support/dependencies.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb index 787437c49a..dab6fdbac6 100644 --- a/activesupport/lib/active_support/dependencies.rb +++ b/activesupport/lib/active_support/dependencies.rb @@ -331,7 +331,7 @@ module ActiveSupport #:nodoc: if load? log "loading #{file_name}" - # Enable warnings iff this file has not been loaded before and + # Enable warnings if this file has not been loaded before and # warnings_on_first_load is set. load_args = ["#{file_name}.rb"] load_args << const_path unless const_path.nil? -- 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(+) 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(+) 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(-) 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(+) 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(-) 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(-) 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 From e1d0d5ae81d2b02eebb1afbfb79edf0a2da2d48e Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Sat, 4 Dec 2010 22:40:05 -0200 Subject: Fix mime type doc typos --- actionpack/lib/action_dispatch/http/mime_type.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/actionpack/lib/action_dispatch/http/mime_type.rb b/actionpack/lib/action_dispatch/http/mime_type.rb index 08eab5634a..c85aa64572 100644 --- a/actionpack/lib/action_dispatch/http/mime_type.rb +++ b/actionpack/lib/action_dispatch/http/mime_type.rb @@ -173,10 +173,10 @@ module Mime end # input: 'text' - # returend value: [Mime::JSON, Mime::XML, Mime::ICS, Mime::HTML, Mime::CSS, Mime::CSV, Mime::JS, Mime::YAML, Mime::TEXT] + # returned value: [Mime::JSON, Mime::XML, Mime::ICS, Mime::HTML, Mime::CSS, Mime::CSV, Mime::JS, Mime::YAML, Mime::TEXT] # # input: 'application' - # returend value: [Mime::HTML, Mime::JS, Mime::XML, Mime::YAML, Mime::ATOM, Mime::JSON, Mime::RSS, Mime::URL_ENCODED_FORM + # returned value: [Mime::HTML, Mime::JS, Mime::XML, Mime::YAML, Mime::ATOM, Mime::JSON, Mime::RSS, Mime::URL_ENCODED_FORM] def parse_data_with_trailing_star(input) keys = Mime::LOOKUP.keys.select{|k| k.include?(input)} Mime::LOOKUP.values_at(*keys).uniq -- cgit v1.2.3