Created
December 5, 2008 11:32
-
-
Save henrik/32312 to your computer and use it in GitHub Desktop.
Make Rails' parameterize remove apostrophes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveSupport::Inflector | |
# Parameterize "Foo's and Charles's bar" into "foos-and-charles-bar" | |
# instead of into "foo-s-and-charles-s-bar". | |
def parameterize_with_apostrophe_removal(string, sep = '-') | |
string = string.dup | |
string.gsub!(%r{s's\b}i, 's') | |
string.gsub!(%{'}, "") | |
parameterize_without_apostrophe_removal(string, sep) | |
end | |
alias_method_chain :parameterize, :apostrophe_removal | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment