Ruby on Rails Monday, December 10, 2012

Thanks all for your responses. I am looking to use Web sockets.



thanks
ravi

On 10-Dec-2012, at 8:06 PM, Ravi Laudya <ravi@pentaur.com> wrote:

Thanks all for your responses. I am looking to use Web sockets.


thanks
ravi


On 09-Dec-2012, at 11:19 PM, Bill Walton <bwalton.im@gmail.com> wrote:

The other way is to couple your app with either Faye or Juggernaut.

On Sun, Dec 9, 2012 at 8:27 AM, Norbert Melzer <timmelzer@gmail.com> wrote:

I the client poll every few seconds via AJAX. There is no other way.

Am 09.12.2012 14:28 schrieb "Ravi Laudya" <mouryaravi@gmail.com>:
Hello all,

I am writing an app to stream log files (or any files) on the browser as they grow. The idea is that the rails app should do a 'tail -f' on the file and keep sending the data to the browser. I was thinking if there was any way to achieve this in rails.

Through googling, I came across the 'streaming' support in rails. But, I didn't get it working. Here is what I tried

class LogsController < ApplicationController

  def index
    headers['X-Accel-Buffering'] = 'no'
    self.status = 200
    self.response_body = Streamer.new
  end

end

class Streamer
  def each
    100000.times do |n|
      yield "Streaming...#{n} "
      if (n % 1000 == 0)
        sleep 1
      end
    end
  end
end

The browser time outs waiting for the data.

Can you please let me know how can I achieve this functionality in rails?


thanks
ravi

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


No comments:

Post a Comment