I have a file, a non-ruby executable or zip file, and I want to trigger the standard "Save file As" dialog. What is the RoR way to do this? - - - - I have scoured the net and the only think I can come up with is some Javascript that gets triggered when the user clicks on an image. function my_onclick() { alert(''This is an alert''); var url=''/LaunchBrowser.zip''; // window.location = url window.open(url,''Download''); }; The javascript runs but it opens a new browser tab/window with the following error: Routing Error No route matches "/LaunchBrowser.zip" with {:method=>:get} - - - - Surely there must be a simple way to enable the user to download a file that they want to get and that I want to give them. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Fri, Nov 19, 2010 at 9:28 AM, Ralph Shnelvar <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I have a file, a non-ruby executable or zip file, and I want to trigger > the standard "Save file As" dialog.> Surely there must be a simple way to enable the user to download a file > that they want to get and that I want to give them.What''s wrong with putting it somewhere under /public and providing that URL? -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org twitter: @hassan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hassan, Friday, November 19, 2010, 10:37:36 AM, you wrote: HS> On Fri, Nov 19, 2010 at 9:28 AM, Ralph Shnelvar <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:>> I have a file, a non-ruby executable or zip file, and I want to trigger >> the standard "Save file As" dialog.>> Surely there must be a simple way to enable the user to download a file >> that they want to get and that I want to give them.HS> What''s wrong with putting it somewhere under /public and providing HS> that URL? HS> -- HS> Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org HS> twitter: @hassan I don''t understand. I apologize for being such a novice. I am also running webrick for testing. Does that make a difference? -- Best regards, Ralph mailto:ralphs-bVGy8FV858MAvxtiuMwx3w@public.gmane.org -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I don''t understand. I apologize for being such a novice. I am also running webrick for testing. Does that make a difference? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Fri, Nov 19, 2010 at 9:57 AM, Ralph Shnelvar <ralphs-bVGy8FV858MAvxtiuMwx3w@public.gmane.org> wrote:>>> Surely there must be a simple way to enable the user to download a file >>> that they want to get and that I want to give them. > > HS> What''s wrong with putting it somewhere under /public and providing > HS> that URL?> I don''t understand. I apologize for being such a novice.Files under RAILS_ROOT/public are directly accessible -- like your app''s javascript, css, or image files.> I am also running webrick for testing. Does that make a difference?Nope. -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org twitter: @hassan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Directly accessible how? What do you recommend as the way to trigger the save dialog? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Fri, Nov 19, 2010 at 10:26 AM, Ralph Shnelvar <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Directly accessible how?Just provide a link with that URL. This is a basic web operation.> What do you recommend as the way to trigger the save dialog?If the file has a .zip or .exe extension, it should be automatic. -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org twitter: @hassan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hassan Schroeder wrote in post #962641:> On Fri, Nov 19, 2010 at 10:26 AM, Ralph Shnelvar <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> > wrote: >> Directly accessible how? > > Just provide a link with that URL. This is a basic web operation. >What kind of link? <a ...> ... </a> ? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Fri, Nov 19, 2010 at 10:59 AM, Ralph Shnelvar <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:>> Just provide a link with that URL. This is a basic web operation. > > What kind of link? <a ...> ... </a>Yes. A standard web hyperlink. -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org twitter: @hassan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hassan Schroeder wrote in post #962645:> On Fri, Nov 19, 2010 at 10:59 AM, Ralph Shnelvar <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> > wrote: > >>> Just provide a link with that URL. This is a basic web operation. >> >> What kind of link? <a ...> ... </a> > > Yes. A standard web hyperlink.In other words: there''s nothing magical about HTML files or images. The browser is smart enough to do the right thing with any content you provide -- even if that "right thing" is saving for use with another application. The reason that it''s so hard to explicitly trigger a Save dialog in the browser is that there''s never any need to do so!> > -- > Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > twitter: @hassanBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org Sent from my iPhone -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I am so frustrated. My HAML code is %div{''id'' => becca_chap_1_human_img_div} %a{''id'' => download_file_a, ''href'' => ''/public/LaunchBrowser.zip''} = image_tag(''PhotosOfBecca.png'', :''id'' => becca_chap_1_human_img) The HAML parses correctly ... Yet when I click on the image I get a routing error Routing Error No route matches "/public/LaunchBrowser.zip" with {:method=>:get} What am I doing wrong? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Fri, Nov 19, 2010 at 3:09 PM, Ralph Shnelvar <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> %a{''id'' => download_file_a, ''href'' => ''/public/LaunchBrowser.zip''}You could look at your css/js/image references as examples, as I said previously...> No route matches "/public/LaunchBrowser.zip" with {:method=>:get}.. which would show you that ''/public'' is *not* part of the URL. -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org twitter: @hassan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I''m sorry, Hassan, I still don''t get it. When I make that link, i.e. /public/LaunchBrowser.zip why is the link going through rails routing? If I make the link LaunchBrowser.zip then rails seems to want the link to be http://localhost:3000/marketing/LaunchBrowser.zip which makes sense because the the file setting up the link to LaunchBrowser.zip is F:\Ralph-Rails-Apps\UltraDedup\app\views\marketing\demodownload.haml Again, sorry to be so dense. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Fri, Nov 19, 2010 at 5:21 PM, Ralph Shnelvar <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> If I make the link > LaunchBrowser.zip > then rails seems to want the link to be > http://localhost:3000/marketing/LaunchBrowser.zip > which makes sense because the the file setting up the link to > LaunchBrowser.zip is > F:\Ralph-Rails-Apps\UltraDedup\app\views\marketing\demodownload.hamlBecause you haven''t made it "/LaunchBrowser.zip". Have you *looked* at any of your standard css/js/image file URLs that currently live under RAILS_ROOT/public? Pick one. Look at the generated markup for that. If that doesn''t answer your questions, ask again, pasting it in as an example. -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org twitter: @hassan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.