geniusfox
(geniusfox)
June 15, 2009, 2:42am
1
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@qunar.com'
@from = 'qiang.zhou@qunar.com'
@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?
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...@qunar.com '
@from = 'qiang.z...@qunar.com '
@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
That'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