【发布时间】:2013-03-21 23:45:06
【问题描述】:
这是我的代码。我正在尝试使用@second_results 获取下一页结果。但它似乎只是复制从@first_results 收到的任何内容。
search = TwitterManualSearch.new
@first_results = search.first_query(:tag => params[:search]).results
@second_results = search.second_query(:tag => params[:search], :since_id => @first_results.results.last.id, :max_id => @first_results.max_id).results
为了您的参考,我写了一些方法来减轻呼叫,我在这里使用 twitter gem - https://github.com/sferik/twitter
我知道我做错了什么,但这是什么?
更新:给你一个简短、粗略和快速的想法,这就是我使用代码返回结果的方式(不包括我所有的方法)
为了获得第一批结果,我这样做了
@first_results = Twitter.search("#tag", :count => 30, :result_type => "recent")
@first_results.results.map do |status|
"#{status.from_user}: #{status.text}"
end
然后再获得更多结果
@second_results = search.second_query("#tag", :count => 30, :result_type => "recent", :since_id => @first_results.results.last.id, :max_id => @first_results.max_id).results
@second_results.map do |status|
"#{status.from_user}: #{status.text}"
end
谢谢
【问题讨论】:
-
您能否提供完整的上下文,说明您在哪里调用它以及您为减轻调用而编写的方法是什么?
-
我已经更新了这个问题。如果我删除我的方法/类,更新代码就是它所做的。
标签: ruby-on-rails ruby ruby-on-rails-3 twitter