diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2015-11-07 21:20:57 +0100 |
---|---|---|
committer | Kasper Timm Hansen <kaspth@gmail.com> | 2015-11-07 21:20:57 +0100 |
commit | ccdc84c09c618cc931e67da83873ad43f4ff8ff8 (patch) | |
tree | ead47836aa2e3f0738769545ffa4ef67da997715 /guides | |
parent | cfd5b0007bfc0d6d25d81cd381c808d5ae6b2dd8 (diff) | |
parent | c9143e15a1ba75137d6c9fe844d8b27dbc412835 (diff) | |
download | rails-ccdc84c09c618cc931e67da83873ad43f4ff8ff8.tar.gz rails-ccdc84c09c618cc931e67da83873ad43f4ff8ff8.tar.bz2 rails-ccdc84c09c618cc931e67da83873ad43f4ff8ff8.zip |
Merge pull request #21897 from swaathi/master
Parameterize with options to preserve the case of string
Diffstat (limited to 'guides')
-rw-r--r-- | guides/source/active_support_core_extensions.md | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md index f6fc255c24..181dca4b71 100644 --- a/guides/source/active_support_core_extensions.md +++ b/guides/source/active_support_core_extensions.md @@ -1710,6 +1710,20 @@ The method `parameterize` normalizes its receiver in a way that can be used in p "Kurt Gödel".parameterize # => "kurt-godel" ``` +To preserve the case of the string, set the `preserve_case` argument to true. By default, `preserve_case` is set to false. + +```ruby +"John Smith".parameterize(preserve_case: true) # => "John-Smith" +"Kurt Gödel".parameterize(preserve_case: true) # => "Kurt-Godel" +``` + +To use a custom separator, override the `separator` argument. + +```ruby +"John Smith".parameterize(separator: "_") # => "john\_smith" +"Kurt Gödel".parameterize(separator: "_") # => "kurt\_godel" +``` + In fact, the result string is wrapped in an instance of `ActiveSupport::Multibyte::Chars`. NOTE: Defined in `active_support/core_ext/string/inflections.rb`. |