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.
05337aed68267daec2996e5ca732d476?d=identicon&s=25 Akbar Home (rinda)
on 2007-03-15 05: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.
70225136eacd3d870f64e03bff678655?d=identicon&s=25 Russell Norris (Guest)
on 2007-03-15 16:14
(Received via mailing list)
You'd put it in your lib directory.

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