Depending where the PDF comes from, the following may help you. I have an application where I store a lot of things, and some of them have (additional) PDFs connected to the items. I store the items in the directory /public/res//
. res
means result, and item_id
is the numeric id of that item in Rails.
In the view, I provide a link to the PDFs by the following (pseudo-)code as a helper method, that may be used in the view:
def file_link(key, name = nil)
res= Ressource.find(:first, :conditions => ["key = ?", key])
list = Dir["public/res/#{res.id}/*"]
file= list.empty? ? "" : list[0]
return file if file.empty?
fn = name ? name : File.basename(file)
link_to fn, "/res/#{res.id}/#{File.basename(file)}", :popup => true
end
The relevant part here is the link_to name, "/res/#{res.id}/#{File.basename(file)}"
thing.