Method in Model

I have a simple method in a model, to send out e-mails via the
script/runner.

def Reminder.dropoff
@messages = Reminder.find(:all, :conditions => [ “time < now()”])
@messages.each do |mes|
Mailman::deliver_send_message(mes)
end
end

However, it’s not sending e-mails.

When this exact code was dropped in a controller, it worked great… is
there something different about methods in models that I would need to
apply here?

Thanks!
-stirman

Or perhaps an alternate question…

Can you call methods in a Controller from a Model?

Thanks,
-stirman

Jason S. wrote:

Or perhaps an alternate question…

Can you call methods in a Controller from a Model?

Thanks,
-stirman

The way I have accomplished this in the past is by making the method an
action on a controller, then activating it with “wget
http://localhost/controller/action”. You can just run that command from
a cron job and be good to go.

Hope this helps.

Jason S. wrote:

Indeed, worked perfect.

Are there any performance hits using wget vs. script/runner? Any
obvious reason to use one over the other?

Thanks again!
-stirman

I can’t imagine there being a performance hit for accessing the action
via wget. Think about it: all it does is hit your existing web server
with a request. You don’t even have to return anything if you don’t want
to. I don’t know how script/runner does its magic, but it can’t be much
different.

Overall, I just feel more comfortable having the system respond to
events the same way in every case, instead of building a custom
interface for some scheduled task.

Indeed, worked perfect.

Are there any performance hits using wget vs. script/runner? Any
obvious reason to use one over the other?

Thanks again!
-stirman

Bryan D. wrote:

The way I have accomplished this in the past is by making the method an
action on a controller, then activating it with “wget
http://localhost/controller/action”. You can just run that command from
a cron job and be good to go.

Hope this helps.

#if bryan.duxbury /* Jun 12, 11:51 */

http://localhost/controller/action". You can just run that command from
a cron job and be good to go.

Hope this helps.
#endif /* [email protected] */

One thing i would add to that is, consider the security implications of
doing it this way. someone in $internet_land could invoke that method
at will. Unless of course, you protect access to it.


keys: http://codex.net/gpg.asc

The trouble with the world is that the stupid are cocksure
and the intelligent are full of doubt.
– Bertrand Russell