Chris, I think you need 2 separate controller actions for this, but you can link them together seamlessly from the clients perspective.
First, have a separate controller action for rendering the PDF. Then, in the first controller action your send back some javascript that would update your view, and then do a window.location to have the browser fetch the PDF. - John On Mon, Jul 19, 2010 at 11:38 PM, 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
