Reputation: 227
I've uploaded a file, Resume.pdf, to the "images" folder in my "assets" folder. How can I create a link that will allow my users to open it?
In my WelcomeController, I have
def readpdf
send_file(Rails.root.join("public", "assets", "Resume.pdf").to_s, :disposition => "inline", :type => "application/pdf")
end
My link is:
<li><%= link_to "RESUME", {:controller=>"welcome", :action=>'readpdf'}, :target=>'_blank' %> %></li>
I keep getting the error
ActionController::MissingFile in WelcomeController#readpdf
Cannot read file /home/action/workspace/wolframpant/public/assets/images/Resume.pdf
I know similar questions have been asked (particularly here), but as far as I can tell I'm doing everything the answers to those questions suggested.
Thank you for your help!
Upvotes: 1
Views: 3916
Reputation: 42799
To access the asset it self you can use
<%= asset_path 'Resume.pdf' %>
To turn it to a link then couple it with a link_to
<% link_to 'Download the resume', asset_path 'Resume.pdf' %>
Upvotes: 2