Multiple render :text, live

Discussion in 'Ruby' started by knohr, May 1, 2007.

  1. knohr

    knohr Guest

    <disclaimer>I'm new to rails and ruby</disclaimer>
    Sorry for the x-post.

    I am using "activescaffold" and have a model that takes some time to
    complete, I would like to have it update the page multiple times while
    'foo' runs.

    basically i have the following

    def foo
    render :text => "starting"
    ......
    end

    It displays the text properly, but not untill 'foo' has completed.

    What I would like to do is something like the following.

    def foo
    render :text => "starting"
    ....
    render :text => "#{iteration} / #{total_iterations}"
    ....
    render :text => "complete"
    end
     
    knohr, May 1, 2007
    #1
    1. Advertising

  2. On 5/1/07, knohr <> wrote:
    > <disclaimer>I'm new to rails and ruby</disclaimer>
    > Sorry for the x-post.
    >
    > I am using "activescaffold" and have a model that takes some time to
    > complete, I would like to have it update the page multiple times while
    > 'foo' runs.


    You'd be much better asking on the rails google group but:

    >
    > basically i have the following
    >
    > def foo
    > render :text => "starting"
    > .....
    > end


    I assume that you mean that this is in the controller not the model.

    >
    > It displays the text properly, but not untill 'foo' has completed.
    >
    > What I would like to do is something like the following.
    >
    > def foo
    > render :text => "starting"
    > ...
    > render :text => "#{iteration} / #{total_iterations}"
    > ...
    > render :text => "complete"
    > end


    You're only allowed one render call per controller action. If you call
    render a second time you'll get a DoubleRenderError exception.

    A controller action processes a single http(s) request, and returns
    one response, this is inherent in the design of the http protocol. If
    you've got a copy of Active Web Development with Rails, and if you
    don't, you should, this is described on page 426 of the second
    edition.

    If you want to dynamically update the browser display you need to
    explore techniques like using AJAX to have the browser poll for
    updates.

    And that's DEFINITELY a topic for the rails specific group rather than
    ruby-talk.

    --
    Rick DeNatale

    My blog on Ruby
    http://talklikeaduck.denhaven2.com/
     
    Rick DeNatale, May 2, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lau Lei Cheong

    Page.Render do not render complete page

    Lau Lei Cheong, May 15, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,094
    Lau Lei Cheong
    May 15, 2004
  2. =?Utf-8?B?YWJoaWppdA==?=

    multiple Web Sites in different Live Servers

    =?Utf-8?B?YWJoaWppdA==?=, Dec 29, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    356
    clintonG
    Dec 29, 2004
  3. Greg
    Replies:
    1
    Views:
    730
    Martin Honnen
    Jun 23, 2006
  4. LukeSkywacko
    Replies:
    1
    Views:
    109
    Evertjan.
    Dec 8, 2006
  5. Glenn Gillen
    Replies:
    0
    Views:
    288
    Glenn Gillen
    Nov 17, 2006
Loading...

Share This Page