Very weird ActionMailer issue

I am trying to use one of my ActionMailer models. What I’m trying to do
is deliver an email from within another model.

I keep getting this error:

#<ActionView::ActionViewError: No rhtml, rxml, rjs or delegate template
found for testaroo>

I have checked the spelling about 20 times, check the file locations,
etc. When I run the method from script/runner it works fine. I get the
email. Here is what I’m running:

script/runner ‘Notifier.deliver_testaroo’

Here is the method:

def testaroo(sent_at = Time.now)
subject “Testing”
recipients ‘[email protected]
from “[email protected]
sent_on sent_at
end

Why does it work in script/runner but not in another model?

Thanks for your help.

Ben J. wrote:

I am trying to use one of my ActionMailer models. What I’m trying to do
is deliver an email from within another model.

I keep getting this error:

#<ActionView::ActionViewError: No rhtml, rxml, rjs or delegate template
found for testaroo>

I have checked the spelling about 20 times, check the file locations,
etc. When I run the method from script/runner it works fine. I get the
email. Here is what I’m running:

script/runner ‘Notifier.deliver_testaroo’

Here is the method:

def testaroo(sent_at = Time.now)
subject “Testing”
recipients ‘[email protected]
from “[email protected]
sent_on sent_at
end

Why does it work in script/runner but not in another model?

Thanks for your help.

Does it work from a controller (instead of a model)?

Michael

Yes.

Michael M. wrote:

Ben J. wrote:

Yes.

Should models be calling other models? It seems the controller should
interact with the model.

I’ll probably get blasted by everyone who reads this but it seems wrong
to have a model call a model.

Michael

Not to send emails. What if I want to send an email on a model action?
Maybe if you modify a user or something. I don’t know, but I don’t see
why that’s wrong.

This is probably the strangest issue I’ve had with rails.

Ben J. wrote:

Michael M. wrote:

Ben J. wrote:

Yes.

Should models be calling other models? It seems the controller should
interact with the model.

I’ll probably get blasted by everyone who reads this but it seems wrong
to have a model call a model.

Michael

Not to send emails. What if I want to send an email on a model action?
Maybe if you modify a user or something. I don’t know, but I don’t see
why that’s wrong.

This is probably the strangest issue I’ve had with rails.

Ben,

Why don’t you just have your model call a function on its own controller
and then have that function send the email? Maybe that will work…

Michael

Ben J. wrote:

Yes.

Should models be calling other models? It seems the controller should
interact with the model.

I’ll probably get blasted by everyone who reads this but it seems wrong
to have a model call a model.

Michael