Initializers - Metaprogramming (uninitialized constant Net (NameError)

Hi guys,

I´m trying to change a SMTP method on my rails application creating a
file on initializers folder, but I'm getting this error: uninitialized
constant Net (NameError)

I don't know if I'm doing this right, here it's my .rb file I put on
initializers folder.

initializers/test.rb
Net::SMTP.class_eval do
  def rcptto(to_addr)
    if $SAFE > 0
      raise SecurityError, 'tainted to_addr' if to_addr.tainted?
    end
    getok("RCPT TO:<#{to_addr}>")
  end
end

Thanks guys...

Hi guys,

I´m trying to change a SMTP method on my rails application creating a
file on initializers folder, but I'm getting this error: uninitialized
constant Net (NameError)

I don't know if I'm doing this right, here it's my .rb file I put on
initializers folder.

sounds like net/smtp isn't yet loaded - try requiring it first.

Fred

Sorry my ignorance Frederick, how can I do that ?

Just for you know, this class is native from Ruby.

Thank you.

Sorry my ignorance Frederick, how can I do that ?

Just for you know, this class is native from Ruby.

require 'net/smtp'
Just because something is part of the ruby standard library doesn't
mean it is loaded all the time - would be rather wasteful to do that.

Fred