Hi,
Suppose I want to redefine the Ruby String class in a Rails app. In
which
file is it the most suitable to write the redefinition?
Thanks
Guillaume C.
Hi,
Suppose I want to redefine the Ruby String class in a Rails app. In
which
file is it the most suitable to write the redefinition?
Thanks
Guillaume C.
any file … as long its visible to your application and require for
that
file returns true
for example you have a file called thisfile.rb
all you have to do in that file is
class String
def yourMethod
#do something
end
end
and wherever you need it just do this
require ‘thisfile’
-daya
…and “thisfile.rb” should go into the model, controller or helpers
folder?
Guillaume C.
lib
Max
ok thanks.
Another question… once I start my Webrick server, the String class
gets
redefined well the first time but all subsequent changes goes unnoticed
by
the requests. I have to restart my webserver…
Why is this happening?
Is there a way to avoid it?
Guillaume C.
never got an answer
anyone?
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs