Topic: Noob: visitors to download pdf file from static site created in Rail3?
After well over 6 hours of pretty satisfying but fruitless work I'm finally crying mama and throwing myself on the mercy of this august forum. I can't figure out how to arrange for visitors to a currently completely static webpage created in RoR3 can download a pdf file from it. Anyone have any leads?
I've tried storing the file in lib/ and public/ -- there is no need for any type of protection for the file.
I've tried just using HTML on the page where the download should occur. Things like:
<a href="[rails root directory]/[app name]/public/[filename].pdf"></a>
which generates a link but produces a "Routing Error No route matches "/public/[filename].pdf"
I've tried things like:
<%= link_to 'Download PDF', '/public/champhandbook.pdf' %>
which generatesthe same routing error.
I've also tried:
<%= button_to "Download File", :action=>'pdf_download'%>
send_file(public/champhandbook.pdf) # or send_file(/public/champhandbook.pdf)
This seems to mess up the routes to the page with the "download pdf" link on it.
I think that I should probably add something to the config/routes.rb file though I'm not sure what. I've tried 'get /[file path] and different iterations of 'match#[ ] but nothing seems to work. Forgive me if this is very very basic.
If anyone has any thoughts, I'd be super grateful!
Basically I'm 8 chapters in to Michael Hartl's excellent Ruby on Rails Tutorial. My brother has a static webpage -- literally one page -- where I arranged for people to download a free ebook pdf file he wrote. I figured that since its current hosting is about to expire, why not spread its current single page form over several pages and apply and reinforce some of the little Rails I've picked up. I'm pretty much starting from very little knowledge. Over the weekend I got most of the site up and it looks pretty good. My brother's happy. I'm completely stuck with putting up a link where people can download the file, the raison d'être of the whole site.
Last edited by BenU (2011-01-11 22:55:12)