Hi Chris,

Does your pdf generator also make a request to the same rails app?

I suspect what might be happening is you are making a second request to the
same app from within your first request,  and you are deadlocked because
request 1 can't return until request 2 is finished.  Is it returning an
error or is it just freezing up on you?

You may want to look into using something like delayed_job, or caching the
html page first.

Hope this helps.

Peter


On Tue, Jul 20, 2010 at 8:33 AM, Martin Emde <[email protected]> wrote:

> Without JavaScript: post to a page that creates and sends the PDF,
> marks the model sent, then redirects back to the view you're showing.
>
> With JavaScript: make the link do an Ajax post that sends the email
> and changes the model, then responds with the information needed to
> update the HTML live.
>
> Maybe I'm not totally understanding because I don't see where you
> might be getting double render. Are you trying to show the user the
> PDF also? If that's the case, JavaScript popup widow for the PDF and
> JavaScript to update the page after Ajax.
>
> Good luck!
>
> Martin
>
> / on my iPhone
>
> On Jul 19, 2010, at 23:38, Chris McCann <[email protected]> wrote:
>
> > SD Ruby,
> >
> > I'd like to be able to render a file, update a model attribute and
> > update a div on a page in a single controller action but can't figure
> > how to do it or if it's possible.
> >
> > The scenario is that I have a model with a "letter_sent" boolean
> > attribute.  A list of these model objects is displayed in a table in a
> > view.
> >
> > For each model instance if letter_sent == false a link is shown in
> > that column that the user can click to generate the letter (it renders
> > a PDF file using wickedhtml).
> >
> > I'd also like to then update the "letter_sent" attribute to true and
> > change the link that was used to fire the action to show an icon
> > indicating the letter has been sent for that instance.
> >
> > So it basically seems like I have three things I'm trying to do, all
> > in one controller action:
> >
> > 1. Generate the letter and render the PDF to the browser as a file
> > 2. Update the letter_sent attribute
> > 3. Update the view to show that the letter was generated
> >
> > I can do either 1 and 2 or 2 and 3 but I'll be darned if I can figure
> > out how to to all 3.  Perhaps it's a "forest and trees" problem.  The
> > "one redirect per controller action" rule has got me stymied.
> >
> > If anyone has a suggestion I'd appreciate hearing from you!
> >
> > Cheers,
> >
> > Chris
> >
> > --
> > SD Ruby mailing list
> > [email protected]
> > http://groups.google.com/group/sdruby
>
> --
> SD Ruby mailing list
> [email protected]
> http://groups.google.com/group/sdruby
>



-- 
Peter Gumeson
[email protected]

-- 
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby

Reply via email to