SOLVED] posted initially as a question
I am testing a ruby 1.9.2 script (it’ll be run in a cron task
later…) in which I am trying to use ActionMailer
All my files are in a single folder 'joinus_email
- joinus_email
joinus_email.rb
notifier.rb- notifications
joinus_email.html.erb
joinus_email.text.erb
- notifications
running the script joinus_email.rb, (in which I defined the
ActionMailer::Base.smtp_settings)
mail = Notifier.joinus_email(“[email protected]”).deliver
is raising an exception :
exception: Missing template notifier/joinus_email with
{:handlers=>[:erb, :rjs, :builder, :rhtml, :rxml], :formats=>[:html],
:locale=>[:en]}
in view paths
notifier.rb
class Notifier < ActionMailer::Base
default :from => “[email protected]”
def joinus_email(destination, coupon)
@url = “http://example.com”
mail(:template_path => ‘notifications’, :to =>
destination, :subject => “Welcome”) do |format|
format.html
format.text
end
end
end
there was something wrong with the :template_path =>
‘notifications’ parameter…
I tried a relative path : " ./notifications" same error raised
I also tried to define upon initialization : TEMPLATE_ROOT = “./
notifications” in the joinus_email.rb script , same error raised …
I found a trick :
ActionMailer::Base.prepend_view_path(’/my/other/path/to/search/first/’)
so in my case , I renamed the notifications folder to notifications
and I wrote :
ActionMailer::Base.prepend_view_path(’./’)
et voilà … hope it’ll help someone…