My goal is to send a static pdf file to a user. I tried the following in my main controller and it barfed badly when I went to http://127.0.0.1:3000/main/file def file if @request.env[''HTTP_USER_AGENT''] =~ /msie/i @headers[''Pragma''] = '''' @headers[''Cache-Control''] = '''' else @headers[''Pragma''] = ''no-cache'' @headers[''Cache-Control''] = ''no-cache, must-revalidate'' end send_file RAILS_ROOT + ''/my_file.pdf'' end I went to http://wiki.rubyonrails.com/rails/pages/HowtoSendFiles The file information there cannot be copied and pasted. Can anyone help me either send the pdf by the above or make the code at the wiki work correctly so it can be cut and pasted to work? This is rails. It should be easier then this.
Why not just put it in the public directory? On 10/3/05, Skriloff, Nicholas <SkriloffN-f4ouqFeUts2a0hU+lRkGgZVzexx5G7lz@public.gmane.org> wrote:> My goal is to send a static pdf file to a user. I tried the following > in my main controller and it barfed badly when I went to > http://127.0.0.1:3000/main/file > > > def file > if @request.env[''HTTP_USER_AGENT''] =~ /msie/i > @headers[''Pragma''] = '''' > @headers[''Cache-Control''] = '''' > else > @headers[''Pragma''] = ''no-cache'' > @headers[''Cache-Control''] = ''no-cache, > must-revalidate'' > end > send_file RAILS_ROOT + ''/my_file.pdf'' > end > > I went to http://wiki.rubyonrails.com/rails/pages/HowtoSendFiles > > The file information there cannot be copied and pasted. Can anyone help > me either send the pdf by the above or make the code at the wiki work > correctly so it can be cut and pasted to work? This is rails. It should > be easier then this. > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
I will try that but why should that matter? What would the code do differently? -----Original Message----- From: rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Kyle Maxwell Sent: Monday, October 03, 2005 11:44 PM To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails] getting a static pdf to the user Why not just put it in the public directory? On 10/3/05, Skriloff, Nicholas <SkriloffN-f4ouqFeUts2a0hU+lRkGgZVzexx5G7lz@public.gmane.org> wrote:> My goal is to send a static pdf file to a user. I tried the following > in my main controller and it barfed badly when I went to > http://127.0.0.1:3000/main/file > > > def file > if @request.env[''HTTP_USER_AGENT''] =~ /msie/i > @headers[''Pragma''] = '''' > @headers[''Cache-Control''] = '''' > else > @headers[''Pragma''] = ''no-cache'' > @headers[''Cache-Control''] = ''no-cache, > must-revalidate'' > end > send_file RAILS_ROOT + ''/my_file.pdf'' > end > > I went to http://wiki.rubyonrails.com/rails/pages/HowtoSendFiles > > The file information there cannot be copied and pasted. Can anyonehelp> me either send the pdf by the above or make the code at the wiki work > correctly so it can be cut and pasted to work? This is rails. Itshould> be easier then this. > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
If you did that, the web server would handle it, and you wouldn''t need to write any code. You''d just link to it. On 10/5/05, Skriloff, Nicholas <SkriloffN-f4ouqFeUts2a0hU+lRkGgZVzexx5G7lz@public.gmane.org> wrote:> I will try that but why should that matter? What would the code do > differently? > > -----Original Message----- > From: rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Kyle Maxwell > Sent: Monday, October 03, 2005 11:44 PM > To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: Re: [Rails] getting a static pdf to the user > > Why not just put it in the public directory? > > On 10/3/05, Skriloff, Nicholas <SkriloffN-f4ouqFeUts2a0hU+lRkGgZVzexx5G7lz@public.gmane.org> wrote: > > My goal is to send a static pdf file to a user. I tried the following > > in my main controller and it barfed badly when I went to > > http://127.0.0.1:3000/main/file > > > > > > def file > > if @request.env[''HTTP_USER_AGENT''] =~ /msie/i > > @headers[''Pragma''] = '''' > > @headers[''Cache-Control''] = '''' > > else > > @headers[''Pragma''] = ''no-cache'' > > @headers[''Cache-Control''] = ''no-cache, > > must-revalidate'' > > end > > send_file RAILS_ROOT + ''/my_file.pdf'' > > end > > > > I went to http://wiki.rubyonrails.com/rails/pages/HowtoSendFiles > > > > The file information there cannot be copied and pasted. Can anyone > help > > me either send the pdf by the above or make the code at the wiki work > > correctly so it can be cut and pasted to work? This is rails. It > should > > be easier then this. > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >