aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorAditya Kapoor <adityakapoor.mait@gmail.com>2017-11-01 12:00:17 +0530
committerAditya Kapoor <adityakapoor.mait@gmail.com>2017-11-01 12:00:17 +0530
commit23d5d5830690a8d22f0fe3762a8399a1f8a6d069 (patch)
tree6d6db2552cea4d69567744429f5ab3b28de4cd4a /activesupport
parenta8ebd48559bea8893aa299f9e27758da0807ef24 (diff)
downloadrails-23d5d5830690a8d22f0fe3762a8399a1f8a6d069.tar.gz
rails-23d5d5830690a8d22f0fe3762a8399a1f8a6d069.tar.bz2
rails-23d5d5830690a8d22f0fe3762a8399a1f8a6d069.zip
[ci skip] show the correct example to demonstrate inflections.
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/inflector/transliterate.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/inflector/transliterate.rb b/activesupport/lib/active_support/inflector/transliterate.rb
index 9801f1d118..e689f0718e 100644
--- a/activesupport/lib/active_support/inflector/transliterate.rb
+++ b/activesupport/lib/active_support/inflector/transliterate.rb
@@ -76,13 +76,19 @@ module ActiveSupport
# To use a custom separator, override the `separator` argument.
#
# parameterize("Donald E. Knuth", separator: '_') # => "donald_e_knuth"
- # parameterize("^trés|Jolie-- ", separator: '_') # => "tres_jolie"
+ # parameterize("^trés|Jolie__ ", separator: '_') # => "tres_jolie"
#
# To preserve the case of the characters in a string, use the `preserve_case` argument.
#
# parameterize("Donald E. Knuth", preserve_case: true) # => "Donald-E-Knuth"
# parameterize("^trés|Jolie-- ", preserve_case: true) # => "tres-Jolie"
#
+ # It preserves dashes and underscores unless they are used as separators:
+ #
+ # parameterize("^trés|Jolie__ ") # => "tres-jolie__"
+ # parameterize("^trés|Jolie-- ", separator: "_") # => "tres_jolie--"
+ # parameterize("^trés_Jolie-- ", separator: ".") # => "tres_jolie--"
+ #
def parameterize(string, separator: "-", preserve_case: false)
# Replace accented chars with their ASCII equivalents.
parameterized_string = transliterate(string)