문제

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)

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top