Redefine standard classes


#1

Hi,

I need my string in all application (in app directory) has this
method:
“Ruby Is Great”.downscore => “ruby_is_great”

So I redefine String class:
class String
def downscore
self.downcase.gsub(/\s/,’_’)
end
end

The question is where I put this stuff in my ror directory by
convention. Should I put in lib folder or config directory? Right now
waiting your answers, I put it in config/environment.rb.

Thank you.


#2

You’d put it in your lib directory.

RSL