Hi, I''m not sure this is even possible, but has anyone used Ajax in a Rails environment to download a file from a Rails application? I''d like to have a view rendered that says "now downloading your file foo.baz", waits a second or two then automatically calls a controller action that uses the send_file() function to return the file contents. Hopefully the browser would do the right thing with the bytes coming back and save them as "foo.baz" and not try to inject them into a page div? Any advice much appreciated, Stu
Juraci Krohling Costa
2005-Nov-28 01:33 UTC
Re: Can I use Ajax and Rails to download a file?...
You can use the regular redirect... One page shows the message ("downloading file... if download doesn''t starts in x seconds, click here"), and this page have a meta-refresh to a download ling (your action that uses send_file function, with "attachment" as content-display). regards, juca Stuart Hungerford wrote:> Hi, > > I''m not sure this is even possible, but has anyone used Ajax > in a Rails environment to download a file from a Rails > application? > > I''d like to have a view rendered that says "now downloading > your file foo.baz", waits a second or two then automatically > calls a controller action that uses the send_file() function > to return the file contents. > > Hopefully the browser would do the right thing with the bytes > coming back and save them as "foo.baz" and not try to inject > them into a page div? > > Any advice much appreciated, > > > Stu > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Stuart Hungerford
2005-Nov-28 04:19 UTC
Re: Can I use Ajax and Rails to download a file?...
Juraci Krohling Costa wrote:> You can use the regular redirect... One page shows the message > ("downloading file... if download doesn''t starts in x seconds, click > here"), and this page have a meta-refresh to a download ling (your > action that uses send_file function, with "attachment" as content-display).Thanks for that -- I was kind of hoping I could manage the downloading process (including a possibly long waiting period until the file is available) with just partial page updates via Ajax. But, if it''s not doable or reasonable to do it that way I''ll go back to using meta-refresh headers. Stu
I''m working on my second tutorial app (from the Rails book) and hit an immediate roadblock where my controller "admin_controllor.rb" is not being found--the message I''m getting is: Not Found ''/admin'' not found -------------------- WEBrick/1.3.1 (Ruby/1.8.2/2004-12-25) at localhost:3000 I built the rails project and then ran: ruby script/generate scaffold Product Admin Any suggestions for where to start looking? Maybe some tests to run to confirm my installation has not been compromised? Thanks, russ
Were all the files generated? In what path? What''s the url you are using to access the app? Check your spelling "admin_controllor.rb" or "admin_controller.rb" What version of Rails are you using? -- Aníbal Rojas http://www.lacaraoscura.com anibalrojas-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org On 11/28/05, Russ McBride <Russ-m07rNB5i18UAvxtiuMwx3w@public.gmane.org> wrote:> > I''m working on my second tutorial app (from the Rails book) and hit an immediate roadblock where my controller "admin_controllor.rb" is not being found--the message I''m getting is: > > Not Found > ''/admin'' not found > -------------------- > WEBrick/1.3.1 (Ruby/1.8.2/2004-12-25) at localhost:3000 > > I built the rails project and then ran: > ruby script/generate scaffold Product Admin > > Any suggestions for where to start looking? Maybe some tests to run to confirm my installation has not been compromised? > > Thanks, > russ > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >