Hi all: I user the command : ruby script/generate mailer FinanceMailer alert_customer_balance, then ,i have this files: class FinanceMailer < ActionMailer::Base def alert_customer_balance(sent_at = Time.now) @subject = ''FinanceMailer#alert_customer_balance'' @body = {} @recipients = ''qiang.zhou-A0Qnk8eqIkkAvxtiuMwx3w@public.gmane.org'' @from = ''qiang.zhou-A0Qnk8eqIkkAvxtiuMwx3w@public.gmane.org'' @sent_on = sent_at @headers = {} end end After this ,i start ruby with: ruby script/console。 at this consoel enviroment, i put "FinanceMailer.alert_customer_balance", But system return : NoMethodError: undefined method `alert_customer_balance'' for FinanceMailer:Class from c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.3.5/lib/ action_mailer /base.rb:335:in `method_missing'' from (irb):13>>I think maybe some inint method error?
I think my problem is :>> FinanceMailer.new=> nil>>On Jun 15, 10:42 am, geniusfox <genius...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi all: > I user the command : ruby script/generate mailer FinanceMailer > alert_customer_balance, then ,i have this files: > > class FinanceMailer < ActionMailer::Base > > def alert_customer_balance(sent_at = Time.now) > @subject = ''FinanceMailer#alert_customer_balance'' > @body = {} > @recipients = ''qiang.z...-A0Qnk8eqIkkAvxtiuMwx3w@public.gmane.org'' > @from = ''qiang.z...-A0Qnk8eqIkkAvxtiuMwx3w@public.gmane.org'' > @sent_on = sent_at > @headers = {} > end > end > > After this ,i start ruby with: ruby script/console。 at this consoel > enviroment, i put "FinanceMailer.alert_customer_balance", But system > return : > NoMethodError: undefined method `alert_customer_balance'' for > FinanceMailer:Class > > from c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.3.5/lib/ > action_mailer > /base.rb:335:in `method_missing'' > from (irb):13 > > > > I think maybe some inint method error?
Frederick Cheung
2009-Jun-15 06:59 UTC
Re: ActionMailer(1.3.5) model problem in my Rails1.2.5
On Jun 15, 3:42 am, geniusfox <genius...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi all: > I user the command : ruby script/generate mailer FinanceMailer > alert_customer_balance, then ,i have this files: > > class FinanceMailer < ActionMailer::Base > > def alert_customer_balance(sent_at = Time.now) > @subject = ''FinanceMailer#alert_customer_balance'' > @body = {} > @recipients = ''qiang.z...-A0Qnk8eqIkkAvxtiuMwx3w@public.gmane.org'' > @from = ''qiang.z...-A0Qnk8eqIkkAvxtiuMwx3w@public.gmane.org'' > @sent_on = sent_at > @headers = {} > end > end > > After this ,i start ruby with: ruby script/console。 at this consoel > enviroment, i put "FinanceMailer.alert_customer_balance", But systemThat''s not how Action Mailer works. If you define the instance method foo, then it creates for you two class methods: FinanceMailer.create_foo (creates a TMail object representing an email from your foo method) FinanceMailer.deliver_foo (creates and sends an email) Fred> return : > NoMethodError: undefined method `alert_customer_balance'' for > FinanceMailer:Class > > from c:/ruby/lib/ruby/gems/1.8/gems/actionmailer-1.3.5/lib/ > action_mailer > /base.rb:335:in `method_missing'' > from (irb):13 > > > > I think maybe some inint method error?