can rails send data to browser chunk by chunk?
Posted
by Nik
on Stack Overflow
See other posts from Stack Overflow
or by Nik
Published on 2010-05-13T21:59:01Z
Indexed on
2010/05/13
22:04 UTC
Read the original article
Hit count: 234
ruby-on-rails
Hello all,
I have a very large dataset (100,000) to be display, but any browser I tried that on including chrome 5 dev, it make them choke for dozens of seconds (win7 64bit, 4gb, 256gb ssd, c2duo 2.4ghertz). I did a little experiment by
some_controller.rb
def show @data = (1..100000).to_a end
show.html.erb
<% @data.each do |d| %> <%= d.to_s %> <% end%>
as simple as that it chokes the browsers. I know browsers were never built for this, so I thought to let the data come in chunk by chunk, I guess 2000 per chunk is reasonable, but I wouldn't want to make 50 requests each time this view is called, any ideas? It doesn't have to be chunk by chunk if it can be sent all at once.
Best,
© Stack Overflow or respective owner