On Jun 2, 2013, at 11:17 PM, Soichi Ishida wrote:

> Rails 3.2.11
> Sidekiq latest
> 
> My app continues background jobs that generate texts as the output.
> 
> class ProcessText
>    include Sidekiq::Worker
> 
>    def perform(name, count)
>        puts "executing..."
>        @feed = Feed.first
>        @feed.process      # here it returns String results!
>    end
> end
> 
> 
> What I want is basically how to send (or push?) the result texts to a
> particular web page.
> 
> The above function 'perform' is in app/workers directory, as instructed
> in the documentation of Sidekiq.  It must be simple but I am unable to
> find the way to do it yet.
> Somehow I need to let a controller reload the page, OR with the help of
> jquery ajax, to show the results, I guess?
> 
> Could anyone give me tips?

Rails 4 will let you stream the update to the page, but in Rails < 4, you want 
to have the page poll for changes. Use Prototype's Ajax.PeriodicalUpdater or 
whatever the jQuery equivalent is. Prototype's can be configured to throttle 
back the frequency of requests after a period of same-results answers, and of 
course you can remove the behavior once the update has been delivered.

Walter

> 
> soichi
> 
> -- 
> Posted via http://www.ruby-forum.com/.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/903eeb9bf373921c0cade5ca14980eac%40ruby-forum.com?hl=en-US.
> 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 unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/25C16B34-547C-4929-8DBD-9D220BA62776%40wdstudio.com?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to