rendered paste bodyContext is that I'm trying to adapt an ActionMailer to create a mail any time I update a tag in the Eribium CMS.
The error I'm getting:
NoMethodError in Admin/tagsController#update
undefined method `foo' for ContactFormMailer:Class
RAILS_ROOT: ../config/..
Application Trace | Framework Trace | Full Trace
/usr/local/lib/ruby/gems/1.8/gems/actionmailer-1.2.1/lib/action_mailer/base.rb:229:in `method_missing'
#{RAILS_ROOT}/app/controllers/admin/tags_controller.rb:115:in `philip_mail_tomfoolery'
#{RAILS_ROOT}/app/controllers/admin/tags_controller.rb:108:in `update'
/usr/local/lib/ruby/gems/1.8/gems/actionmailer-1.2.1/lib/action_mailer/base.rb:229:in `method_missing'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:910:in `perform_action_without_filters'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:368:in `perform_action_without_benchmark'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'
/usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/rescue.rb:82:in `perform_action'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:381:in `process_without_filters'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:377:in `process_without_session_management_support'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/session_management.rb:117:in `process'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/dispatcher.rb:38:in `dispatch'
dispatch.cgi:10
/usr/local/lib/ruby/gems/1.8/gems/actionmailer-1.2.1/lib/action_mailer/base.rb:229:in `method_missing'
#{RAILS_ROOT}/app/controllers/admin/tags_controller.rb:115:in `philip_mail_tomfoolery'
#{RAILS_ROOT}/app/controllers/admin/tags_controller.rb:108:in `update'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:910:in `perform_action_without_filters'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:368:in `perform_action_without_benchmark'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'
/usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/rescue.rb:82:in `perform_action'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:381:in `process_without_filters'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:377:in `process_without_session_management_support'
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/session_management.rb:117:in `process'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/dispatcher.rb:38:in `dispatch'
dispatch.cgi:10
Request
Parameters: {"commit"=>"Update", "tag"=>{"name"=>"tech", "description"=>"This is an update", "text_filter"=>"markdown"}, "id"=>"1"}
Show session dump
---
:user_id: 1
:jumpto:
flash: !map:ActionController::Flash::FlashHash {}
Response
Headers: {"Status"=>"200 OK", "cookie"=>[], "Cache-Control"=>"no-cache"}
My attempt at calling ActionMailer (hacked into Eribium but this is clearly getting called:
#I'm testing my understanding of ActionMailer....
#More or less hacked from page 416 of the Rails book
def philip_mail_tomfoolery
emailer = ContactFormMailer
emailer.foo
emailer.contact_form
email = ContactFormMailer.contact_form
render (:text => '<pre>' + email.encoded + '</pre>')
end
... and the contact_form_mailer.rb file itself:
class ContactFormMailer < ActionMailer::Base
def foo
puts 555
end
def contact_form(sent_at = Time.now)
@subject = 'Message from ContactFormMailer#contact_form'
@body = {}
@recipients = 'philipreedtech@gmail.com'
@from = ''
@sent_on = sent_at
@headers = {}
end
end