I tried a couple other approaches, but no success yet: 1. I reversed the blocks below - calling the load_images from within render :update - that did give me the results, but all at once in the end, not as the images show up. 2. I called redirect_to <controller/show_image?image_id=1 within the inner loop in 1, and created a show_image.js.rjs file which calls page.insert_html :bottom, 'images-div', :partial => 'image', but I get an error 'ActionView::MissingTemplate (Missing template <mycontroller>/ show_image.erb in view path app/views) I dont really understand why this is happening - shouldnt it pick the rjs template if present instead of the erb?
What I really want is to leverage http to parallelize the retrieval and rendering of images. How do I do that? Thanks Anand On May 3, 9:11 am, candor <rcan...@gmail.com> wrote: > Hi, > > I have a rails application where I respond to a request by fetching > image urls from various web api calls and need to display them as they > come available. I am able to display all the images once I get them > all, but that causes an unacceptable delay for my user. > > One approach I am trying is, from my controller, set an @image > variable, and then pass in a block to the model that retrieves the > image urls. In the block, I call > In the controller, I have: > @query.load_images! do |image| > @image = image > render :update do |page| > page.insert_html :bottom, 'images-div', :partial => 'images' > end > end > > In my query model, I have: > > def load_images! &block > for(some_loop_that_gets_one_image_at_a_time) do > image = get_next_image > block.call(image) > end > end > > In the _images.html.erb, I have: > > <%=image_tag @image.url %> > > The problem is that with this approach, I get a DoubleRenderError, and > I think this is because render is being called multiple times in the > block call within the loop. > > What is the best way to get the effect I need (to load images one at a > time as they become available)? > > Thanks > Anand > > -- > 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-t...@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/rubyonrails-talk?hl=en. -- 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.