From 2e454b906d80bddcceed91be7b42b1be02bdad6c Mon Sep 17 00:00:00 2001 From: DonGiulio Date: Thu, 20 Feb 2014 13:24:47 +0100 Subject: [PATCH] use parameterize to convert the string this is more efficient, and works on more cases. parameterize was introduced in rails 2.3.2 --- lib/dehumanize.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/dehumanize.rb b/lib/dehumanize.rb index becdca7..faa520f 100644 --- a/lib/dehumanize.rb +++ b/lib/dehumanize.rb @@ -1,6 +1,6 @@ module ActiveSupport::Inflector - def dehumanize(the_string) - the_string.gsub(' ', '_').downcase + def dehumanize(string) + string.parameterize.underscore end end @@ -8,4 +8,4 @@ class String def dehumanize ActiveSupport::Inflector.dehumanize(self) end -end \ No newline at end of file +end