I have a set of static PDF files. I want to list them on the rails page with links to them.
I need right now how to trim / public from the beginning of the path for the link to actually work.
Current Code:
<h1>Listing letters</h1> <table> <ul> <% @files = Dir.glob("public/files/*.pdf") %> <% for file in @files %> <% new_file = file.to_s %> <% new_file = new_file.chomp("public/") %> <li><%= link_to 'Letter', new_file %></li> <% end %> </ul> </table>
However, the links still go like
http://localhost:3000/public/files/document.pdf
when you need to work, they should be
http://localhost:3000/files/document.pdf
file ruby-on-rails
DVG
source share