Skip to content

Instantly share code, notes, and snippets.

@henrik
Created December 5, 2008 11:32
Show Gist options
  • Save henrik/32312 to your computer and use it in GitHub Desktop.
Save henrik/32312 to your computer and use it in GitHub Desktop.
Make Rails' parameterize remove apostrophes.
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