Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/52.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 在rails 3中向下滚动获取数据_Ruby On Rails_Ruby_Ajax - Fatal编程技术网

Ruby on rails 在rails 3中向下滚动获取数据

Ruby on rails 在rails 3中向下滚动获取数据,ruby-on-rails,ruby,ajax,Ruby On Rails,Ruby,Ajax,我在rails 3.2.1中开发了一个类似twitter的应用程序。在我的索引页面中,我想显示我和我关注的人发布的推文。它工作正常。现在我需要的是避免获取所有推文。起初,我可能只需要前15条tweet,然后当我向下滚动时,下一批15或20条tweet必须附加在底部,就像facebook和twitter一样 我的索引操作如下所示: def index @tweets=Tweet.find(:all,:include =>[:user]) end <% @tweets.e

我在rails 3.2.1中开发了一个类似twitter的应用程序。在我的索引页面中,我想显示我和我关注的人发布的推文。它工作正常。现在我需要的是避免获取所有推文。起初,我可能只需要前15条tweet,然后当我向下滚动时,下一批15或20条tweet必须附加在底部,就像facebook和twitter一样

我的索引操作如下所示:

 def index
     @tweets=Tweet.find(:all,:include =>[:user])
end
 <% @tweets.each do |tweet| %>
      <% if tweet.user==current_user || current_user.following?(tweet.user) %>
         <div class="marginer">
             <%= tweet.user.user_name %> : <%= tweet.message %> 
         </div>
      <% end %>

  <% end %>
“我的视图”部分现在正在获取所有推文,看起来如下所示:

 def index
     @tweets=Tweet.find(:all,:include =>[:user])
end
 <% @tweets.each do |tweet| %>
      <% if tweet.user==current_user || current_user.following?(tweet.user) %>
         <div class="marginer">
             <%= tweet.user.user_name %> : <%= tweet.message %> 
         </div>
      <% end %>

  <% end %>

:  

请帮助

您可以通过AJAX调用服务器来实现这一点,其中包含用户详细信息、批大小和批的开始索引

你可以使用很多jquery插件来实现这一点..比如


请提供一些示例