2

I am pulling email via pop into my Rails 3 application so i have a file called dropbox_receiver.rb in the rails lib directory.

This pulls in all email and calls DropBox.receive(email)

I can run this using rails/runner but when i run it from the daemon_controller.rb file i get the error

initialized constant Object::DropBox

How do i boot rails 3 in this script ?

Also how do i log properly from this script to my production.log?

tshepang
  • 12,111
  • 21
  • 91
  • 136
rick
  • 463
  • 5
  • 23

2 Answers2

1

Put this at the top of your script:

ENV['RAILS_ENV'] = ARGV.first || ENV['RAILS_ENV'] || 'development'               
require File.expand_path(File.dirname(__FILE__) + "/../../config/environment"

That's for a script in app/controllers. You'll need to adjust the path to config/environment if your daemon is elsewhere.

Mori
  • 27,279
  • 10
  • 68
  • 73
0

Also, you're probably going to run into the issue of open files as described here.

Community
  • 1
  • 1
m33lky
  • 7,055
  • 9
  • 41
  • 48