send mail in console, failed for the first time, but successfully sent
after reloading…, following are my code snippet:
class Mailer < ActionMailer::Base
def notification()
…
end
end
class Model < ActiveRecord::Base
def self.send_notifications
mail=Mailer.create_notification()
mail.set_content_type(‘text/html;charset=utf-8’)
Mailer.deliver(mail)
end
end
1 script/console
2 Model.send_notifitions
#failed
ActionView::ActionViewError: No rhtml, rxml, rjs or delegate template
found for notifications in /mailer
from
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/base.rb:399:in
find_template_extension_for' from /opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/base.rb:335:in
pick_template_extension’
from
/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/base.rb:249:in
render_file' from /opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/base.rb:283:in
render’
from
/opt/local/lib/ruby/gems/1.8/gems/actionmailer-1.3.3/lib/action_mailer/base.rb:481:in
render' from /opt/local/lib/ruby/gems/1.8/gems/actionmailer-1.3.3/lib/action_mailer/base.rb:476:in
render_message’
from
/opt/local/lib/ruby/gems/1.8/gems/actionmailer-1.3.3/lib/action_mailer/base.rb:424:in
create!' from /opt/local/lib/ruby/gems/1.8/gems/actionmailer-1.3.3/lib/action_mailer/base.rb:385:in
initialize’
from
/opt/local/lib/ruby/gems/1.8/gems/actionmailer-1.3.3/lib/action_mailer/base.rb:332:in
new' from /opt/local/lib/ruby/gems/1.8/gems/actionmailer-1.3.3/lib/action_mailer/base.rb:332:in
method_missing’
from ./script/…/config/…/config/…/app/models/model.rb:200:in
`send_notifications’
3 reload!
#ok
4 Model.send_notifitions
#sent successfully
how strange, anybody knows? thanks