Forum: Ruby on Rails Redefine standard classes

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Akbar H. (Guest)
on 2007-03-15 06:09
(Received via mailing list)
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.
Russell N. (Guest)
on 2007-03-15 17:14
(Received via mailing list)
You'd put it in your lib directory.

RSL
This topic is locked and can not be replied to.