Erico Fusco
2011-May-02  16:19 UTC
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...
-- 
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung
2011-May-02  16:58 UTC
Re: Initializers - Metaprogramming (uninitialized constant Net (NameError)
On May 2, 5:19 pm, Erico Fusco <ericopfu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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> 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...-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Erico Fusco
2011-May-02  17:36 UTC
Re: Initializers - Metaprogramming (uninitialized constant Net (NameError)
Sorry my ignorance Frederick, how can I do that ? Just for you know, this class is native from Ruby. Thank you. On 2 maio, 13:58, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On May 2, 5:19 pm, Erico Fusco <ericopfu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 > > > 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...-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Frederick Cheung
2011-May-02  18:08 UTC
Re: Initializers - Metaprogramming (uninitialized constant Net (NameError)
On May 2, 6:36 pm, Erico Fusco <ericopfu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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> Thank you. > > On 2 maio, 13:58, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > On May 2, 5:19 pm, Erico Fusco <ericopfu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 > > > > 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...-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.