Tweetstream and Rails - can't get any response

I am using Tweetstream gem for Rails and keep getting stuck waiting for any update..

I basically do the example (with my oauth data etc. of course):

    require 'Tweetstream'

TweetStream.configure do |config|
  config.consumer_key       = 'consumer_key'
  config.consumer_secret    = 'secret'
  config.oauth_token        = 'token'
  config.oauth_token_secret = 'token_secret'
  config.auth_method        = :oauth
end

TweetStream::Client.new.sample do |status|
      puts "SOMETHING HERE?"
  puts "#{status.text}"
end

and nothing happens... the console is just waiting forever for anything to happen..

not even "SOMETHING HERE?" is getting printed..

Answers


I'll take a wild guess and say you are putting this in an initializer? The gem doesn't work this way. TweetStream is an event-based library and has a different runtime profile from that of a Rails app.

You will need to run TweetStream side by side with Rails as a daemon process collecting the tweets, storing them on a DB and Rails will access that same DB.

Use Rails Runner (http://guides.rubyonrails.org/command_line.html#rails-runner) to run your TweetStream daemon on the context of Rails, this should give you access to the models.


Need Your Help

AirPrint and Bonjour

objective-c ipad ios4 bonjour airprint

Do I have to use an Apple AirPrint capable printer to use AirPrint in my iPad app?

Passing parameters into a closure for setTimeout

javascript jquery internet-explorer-9 closures document-ready

I've run into an issue where my app lives in an iframe and it's being called from an external domain. IE9 won't fire the load event when the iframe loads properly so I think I'm stuck using setTim...