Greetings! Is there a way to get RoR to redirect_to another action after doing a sendfile? My little app lets the user enter a bunch of data and then creates an XML file from it. I''m using sendfile to let the user download the XML file. Once they download the file I want to take them to a new view that presents a logout button that will trigger a cleanup. But it looks like RoR treats the sendfile just like a render so the redirect after the sendfile doesn''t work. Anybody know a way around this? Thanks! Bill -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060516/2f194147/attachment.html
Redirect to the logout page first, and offer a link to the download there. You might even load the link automatically after a few seconds with javascript. That''s what most download sites do. On 5/16/06, Bill Walton <bill.walton@charter.net> wrote:> > > Greetings! > > Is there a way to get RoR to redirect_to another action after doing a > sendfile? > > My little app lets the user enter a bunch of data and then creates an XML > file from it. I''m using sendfile to let the user download the XML file. > Once they download the file I want to take them to a new view that presents > a logout button that will trigger a cleanup. But it looks like RoR treats > the sendfile just like a render so the redirect after the sendfile doesn''t > work. > > Anybody know a way around this? > > Thanks! > Bill > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Hi Carl, Carl-Johan Kihlbom wrote:> Redirect to the logout page first, and offer a link to the download there.I really want to avoid having both the logout and download buttons on the same page / view if possible. The users are presumed newbies and if they click the logout button first, they''ll have lost everything they entered. The app ''walks them through'' the data collection process with as few choices as possible other than enter data or don''t enter data.> You might even load the link automatically after a few seconds with > javascript. That''s what most download sites do.Not sure what you''re suggesting here. Could you say more, please? If you''re suggesting just sending them to the logout screen and then invoking sendfile via js, I don''t see how that helps. What''s to prevent them from clicking the logout button if there''s a delay in the save / download dialog appearing? I really want to give them a chance to clean up the file /records they''ve created on the server rather than just waiting for their session to time out. Any other ideas? Anybody else? Thanks! Bill
Hi Bill, To be honest, the only usable way I''ve ever gotten this to work is to open a new window and send the download from there. The fact that Google and others do this makes me a little more comfortable, but on a whole I still think it sucks. -Rob On 5/16/06, Bill Walton <bill.walton@charter.net> wrote:> Hi Carl, > > Carl-Johan Kihlbom wrote: > > > Redirect to the logout page first, and offer a link to the download there. > > I really want to avoid having both the logout and download buttons on the > same page / view if possible. The users are presumed newbies and if they > click the logout button first, they''ll have lost everything they entered. > The app ''walks them through'' the data collection process with as few choices > as possible other than enter data or don''t enter data. > > > You might even load the link automatically after a few seconds with > > javascript. That''s what most download sites do. > > Not sure what you''re suggesting here. Could you say more, please? If > you''re suggesting just sending them to the logout screen and then invoking > sendfile via js, I don''t see how that helps. What''s to prevent them from > clicking the logout button if there''s a delay in the save / download dialog > appearing? > > I really want to give them a chance to clean up the file /records they''ve > created on the server rather than just waiting for their session to time > out. > > Any other ideas? Anybody else? > > Thanks! > Bill > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On 3-jun-2006, at 2:29, Rob Kaufman wrote:> Hi Bill, > To be honest, the only usable way I''ve ever gotten this to work is > to open a new window and send the download from there. The fact that > Google and others do this makes me a little more comfortable, but on a > whole I still think it sucks. >> >> Not sure what you''re suggesting here. Could you say more, >> please? If >> you''re suggesting just sending them to the logout screen and then >> invoking >> sendfile via js, I don''t see how that helps. What''s to prevent >> them from >> clicking the logout button if there''s a delay in the save / >> download dialog >> appearing?Forward the download into an iframe (and change the link to "Wait a moment" - although I hate such meticulousness ;-))), and use a JavaScript timeout to redirect the visitor to the logout page in the parent frame. There, stick a big button "Yes, I have downloaded my file and you can finish my session now". -- Julian ''Julik'' Tarkhanov please send all personal mail to me at julik.nl
Definately RoR treats the send_file just like any other render. What I do is redirect to a "downloading" page that describes the download will happen and also has the logout button. I prefer meta tags over Javascript, and so I add this code to my application.rhtml layout (because meta tags should go inside the HEAD element):> <% if @set_download_refresh_meta %> > <meta http-equiv="refresh" content="2; URL=<%=@download.url%>" /> > <% end %>Just incase the metatag doesn''t work, I always add a comment like this:> Your download should begin shortly. If it does not, > click this link to manually download the file.This is what I do on 1Passwd and it is how many sites like sourceforge and download.com do it. HTH. On Tuesday, May 16, 2006, at 10:01 AM, Bill Walton wrote:>Greetings! > >Is there a way to get RoR to redirect_to another action after doing >a sendfile? > >My little app lets the user enter a bunch of data and then creates >an XML file from it. I''m using sendfile to let the user download >the XML file. Once they download the file I want to take them to a >new view that presents a logout button that will trigger a cleanup. >But it looks like RoR treats the sendfile just like a render so the >redirect after the sendfile doesn''t work. > >Anybody know a way around this? > >Thanks! >Bill > >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/rails >Cheers! --Dave Teare http://1passwd.com - Password Manager + AutoFill for Mac OS X http://devlists.com - Email list management http://palmsphere.com - Apps for your hand-held -- Posted with http://DevLists.com. Sign up and save your mailbox.