Rails dies when I try to call a method from my Mailer. But I have defined my method. What could I have missed? Here is the irb session:>> p = Person.find(1)=> Person data...>> SiteMailer.request_admin_approval(p)NoMethodError: undefined method `request_admin_approval'' for SiteMailer:Class>> SiteMailer.method_defined? :request_admin_approval=> true The method code: class SiteMailer < ActionMailer::Base def request_admin_approval(person) @subject = ''Watercooler - New User Notification'' @body["person"] = person @recipients = "me" @from = ''server-6AQQTOP5xU+Z+DCkdF2Uwti2O/JbrIOy@public.gmane.org'' @sent_on = Time.now @headers = {} end -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Fri, 2007-04-06 at 22:42 +0200, Taylor Strait wrote:> Rails dies when I try to call a method from my Mailer. But I have > defined my method. What could I have missed? Here is the irb session: > > >> p = Person.find(1) > => Person data... > > >> SiteMailer.request_admin_approval(p) > NoMethodError: undefined method `request_admin_approval'' for > SiteMailer:Class > > >> SiteMailer.method_defined? :request_admin_approval > => true > > > The method code: > > class SiteMailer < ActionMailer::Base > > def request_admin_approval(person) > @subject = ''Watercooler - New User Notification'' > @body["person"] = person > @recipients = "me" > @from = ''server-6AQQTOP5xU+Z+DCkdF2Uwti2O/JbrIOy@public.gmane.org'' > @sent_on = Time.now > @headers = {} > end---- try ''self'' def self.request_admin_approval(person) -- Craig White <craig-CnJ8jr4MGtxl57MIdRCFDg@public.gmane.org> --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Taylor Strait wrote:> Rails dies when I try to call a method from my Mailer. But I have > defined my method. What could I have missed? Here is the irb session: > > The method code: > > class SiteMailer < ActionMailer::Base > > def request_admin_approval(person) > #... > endTo call your mail methods, you dont call them directly: SiteMailer.deliver_request_admin_approval(person) Which sends the email and returns a TMail object. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 4/6/07, Taylor Strait <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Rails dies when I try to call a method from my Mailer. But I have > defined my method. What could I have missed? Here is the irb session: > > >> p = Person.find(1) > => Person data... > > >> SiteMailer.request_admin_approval(p) > NoMethodError: undefined method `request_admin_approval'' for > SiteMailer:Class > > >> SiteMailer.method_defined? :request_admin_approval > => trueIt is true... there is a method named request_admin_approval for SiteMailer... but it is an instance method (as in: s = SiteMailer.new s.request_admin_approval(p) ) You''re trying to access it as a class method... which means, you would need to define self.request_admin_approval in the SiteMailer class instead of just request_admin_approval. Or, you will have to make an instance of your SiteMailer object in order to call the function. The method code:> > class SiteMailer < ActionMailer::Base > > def request_admin_approval(person) > @subject = ''Watercooler - New User Notification'' > @body["person"] = person > @recipients = "me" > @from = ''server-6AQQTOP5xU+Z+DCkdF2Uwti2O/JbrIOy@public.gmane.org'' > @sent_on = Time.now > @headers = {} > end > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---