我通过pop将电子邮件拉到我的Rails 3应用程序中,所以我在rails lib目录中有一个名为dropbox_receiver.rb的文件。
这会提取所有电子邮件并调用DropBox.receive(email)
我可以使用rails / runner运行它但是当我从daemon_controller.rb文件运行它时我得到错误
initialized constant Object::DropBox
如何在此脚本中启动rails 3?
另外,我如何从此脚本正确登录到我的production.log?
答案 0 :(得分:1)
将它放在脚本的顶部:
ENV['RAILS_ENV'] = ARGV.first || ENV['RAILS_ENV'] || 'development'
require File.expand_path(File.dirname(__FILE__) + "/../../config/environment"
这适用于app / controllers中的脚本。如果您的守护程序在其他地方,则需要调整config / environment的路径。
答案 1 :(得分:0)
此外,您可能会遇到here所述的打开文件问题。