Skip to content

Commit

Permalink
use parameterize to convert the string
Browse files Browse the repository at this point in the history
this is more efficient, and works on more cases. parameterize was introduced in rails 2.3.2
  • Loading branch information
DonGiulio committed Feb 20, 2014
1 parent 0b475cd commit 2e454b9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/dehumanize.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module ActiveSupport::Inflector
def dehumanize(the_string)
the_string.gsub(' ', '_').downcase
def dehumanize(string)
string.parameterize.underscore
end
end

class String
def dehumanize
ActiveSupport::Inflector.dehumanize(self)
end
end
end

0 comments on commit 2e454b9

Please sign in to comment.