Frage

I'm using Rails 3.2 and I would like to have a side process monitoring a TweetStream using rails runner, unfortunately my Models seem to be empty until I access them using the debugger. What would cause this? Do I need to reconnect to my database? Is this something to do with EventMachine?

More specifically, I have:

charity = Charity.find_by_blah(blah)
if charity.nil?
   binding.pry
   do_stuff
end

And what happens is, charity will be nil and pass the check, but when I try running the command charity = Charity.find_by_blah(blah) in pry, it returns the correct object. Any ideas? I'm running rails s in one tab, and then in another I'm running

rails runner script/tweetstream.rb

(Ideally the tweetstream will be a daemon down the line)

War es hilfreich?

Lösung

Found my error, I had to reconnect to the DB on init.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top