From 51cd6bb829c418c5fbf75de1dfbb177233b1b154 Mon Sep 17 00:00:00 2001 From: David Lee Date: Tue, 7 Jun 2011 19:05:09 -0700 Subject: Refactor --- railties/guides/source/initialization.textile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties/guides') diff --git a/railties/guides/source/initialization.textile b/railties/guides/source/initialization.textile index 1d5b0c0c11..340699419b 100644 --- a/railties/guides/source/initialization.textile +++ b/railties/guides/source/initialization.textile @@ -661,9 +661,9 @@ require 'active_support/inflections' require 'active_support/core_ext/string/inflections' -The +active_support/inflector/methods+ file has already been required by +active_support/autoload+ and so won't be loaded again here. +The +active_support/inflector/methods+ file has already been required by +active_support/autoload+ and so won't be loaded again here. The +activesupport/lib/active_support/inflector/inflections.rb+ is required by +active_support/inflector/methods+. -h4. +activesupport/lib/active_support/inflector/inflections.rb+ +h4. +active_support/inflections+ This file references the +ActiveSupport::Inflector+ constant which isn't loaded by this point. But there were autoloads set up in +activesupport/lib/active_support.rb+ which will load the file which loads this constant and so then it will be defined. Then this file defines pluralization and singularization rules for words in Rails. This is how Rails knows how to pluralize "tomato" to "tomatoes". -- cgit v1.2.3 From d38ca78dbd99be11e64652163924e9456a7a2362 Mon Sep 17 00:00:00 2001 From: David Lee Date: Thu, 9 Jun 2011 01:10:49 -0700 Subject: Add acronym support to Inflector; Issue #1366 --- railties/guides/source/active_support_core_extensions.textile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'railties/guides') diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index 7512f7bcb9..3616e3385c 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -1460,7 +1460,15 @@ end That may be handy to compute method names in a language that follows that convention, for example JavaScript. -INFO: As a rule of thumb you can think of +camelize+ as the inverse of +underscore+, though there are cases where that does not hold: "SSLError".underscore.camelize gives back "SslError". +INFO: As a rule of thumb you can think of +camelize+ as the inverse of +underscore+, though there are cases where that does not hold: "SSLError".underscore.camelize gives back "SslError". To support cases such as this, Active Support allows you to specify acronyms in +config/initializers/inflections.rb+: + + +ActiveSupport::Inflector.inflections do |inflect| + inflect.acronym 'SSL' +end + +"SSLError".underscore.camelize #=> "SSLError" + +camelize+ is aliased to +camelcase+. -- cgit v1.2.3