Open a .pdf file with Rails outside the public folder -


i'm new programming world , i'm working rails create first project. have library of .pdf files saved on separate shared network server. make links of these files when click link, pdf opens in browser.

i understand using:

<a href="/filename.pdf">click me</a> 

i can open file in /public folder in rails project, i'm looking open file on different harddrive. i've tried

`href="//drivename/folder/nextfolder/filename.pdf" ` 

but browser gives me 404 error saying file not found.

better use controller action serve file:

say have pdfs controller,

in view:

<a href="pdfs/serve/filename">click me</a> 

in controller

def serve   path = "/drivename/folder/nextfolder/#{params[:filename]}"    send_file( path,   :disposition => 'inline',   :type => 'application/pdf',   :x_sendfile => true ) end  

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -