How do I convert a Twitter API Pull into an Array in Ruby On Rails?
I am trying to create a stream that includes Twitter data + my app's but I'm having trouble with this because Twitter's data isn't properly coming out as an array. This is my code:
answers = Answer.find(:all, :conditions => {:user_id => @user_id }, 开发者_高级运维:limit => 20)
tweets = Twitter::Search.new(params[:username])
@feed = (answers + tweets).order_by(&:created_at)
Any suggestions would be greatly appreciated.
It looks like you're using the Twitter Gem? In which case, the Search class is Enumerable and you can therefore call to_a on an instance of it. So...
tweets = Twitter::Search.new(params[:username]).to_a
@feed = (answers + tweets).order_by(&:created_at)
精彩评论