开发者

Send ActionMailer from external ruby file?

i want to make a cronjob which execute a specific ruby file in the script dir开发者_Python百科ectory of my rails app. how can i achieve, that i can execute an actionmailer to use deliver? how do i get this mailer into this ruby file?

thanks!


Skipping the part about creating a task in crontab, here is what you can do:

  1. Create a rake task, in lib/tasks, which sends that email and invoke the rake task from your cron job. I have done this and this works, pretty well for me.
  2. Load the Rails environment explicitly in your ruby script. I do this in some daemons. You can do something like this :

    require File.dirname(__FILE__) + "/../config/application"
    Rails.application.require_environment!
    
  3. Use the rails runner. rails runner -h will give you the necessary information

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜