I have a big project I am working on, and like to use file hierarchy conventions to keep portions of the system separated. I ran the following command:
bojo@boji:~/Development/rails/ims$ ruby script/generate mailer work/ mail/notifier create app/models/work/mail create app/views/work/mail/notifier create test/unit/work/mail create test/fixtures/work/mail/notifier create app/models/work/mail/notifier.rb create test/unit/work/mail/notifier_test.rb
Added a method to my model:
class Work::Mail::Notifier < ActionMailer::Base
def project_notification(user) recipients user[:email] from "ims@example.com" subject "Test Mail" # body "user" => user body "Test Mail Body" end
end
And called it from a controller:
Work::Mail::Notifier.deliver_project_notification(params[:project] [:user_id])
This all works fine without calling an actual .rhtml template. However, when I replaced the body method with something that passes instance variables, I get the following error:
ActionView::ActionViewError (No rhtml, rxml, rjs or delegate template found for project_notification): /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/ base.rb:389:in `find_template_extension_for' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/ base.rb:325:in `pick_template_extension' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/ base.rb:240:in `render_file' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_view/ base.rb:274:in `render'
(etc, etc, etc)
I do have a template located at:
app/views/work/mail/notifier/project_notification.rhtml
Am I missing something here, or is the ActionMailer not capable of referencing the .rhtml file right?
Thanks,
Brian Jones