diff options
author | Xavier Noria <fxn@hashref.com> | 2010-03-01 22:58:21 +0100 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2010-03-01 22:58:21 +0100 |
commit | 44bd3bd4ff2705b798313fbbb60cb7064b328f9b (patch) | |
tree | e8a9c77b78ecc9e8b4937f83e8d001addda59199 /railties | |
parent | 71990a4157f37bc7529184654265679a62a9e121 (diff) | |
download | rails-44bd3bd4ff2705b798313fbbb60cb7064b328f9b.tar.gz rails-44bd3bd4ff2705b798313fbbb60cb7064b328f9b.tar.bz2 rails-44bd3bd4ff2705b798313fbbb60cb7064b328f9b.zip |
AS guide: documents String#dasherize
Diffstat (limited to 'railties')
-rw-r--r-- | railties/guides/source/active_support_core_extensions.textile | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile index 5f1849f2b6..e56dde2977 100644 --- a/railties/guides/source/active_support_core_extensions.textile +++ b/railties/guides/source/active_support_core_extensions.textile @@ -1391,6 +1391,27 @@ The method +titleize+ capitalizes the words in the receiver: NOTE: Defined in +active_support/core_ext/string/inflections.rb+. +h5. +dasherize+ + +The method +dasherize+ replaces the underscores in the receiver with dashes: + +<ruby> +"name".dasherize # => "name" +"contact_data".dasherize # => "contact-data" +</ruby> + +The XML serializer of models uses this method to dasherize node names: + +<ruby> +# active_model/serializers/xml.rb +def reformat_name(name) + name = name.camelize if camelize? + dasherize? ? name.dasherize : name +end +</ruby> + +NOTE: Defined in +active_support/core_ext/string/inflections.rb+. + h3. Extensions to +Numeric+ h4. Bytes |