ruby-on-railsruby-on-rails-3link-to

Rails link to file in public folder


I have a file data.txt in the public folder of my Rails project. I want to link to it from one of the pages in my project using link_to. How can I do it?

If I do

<%= link_to "here", "data.txt" %>

it links to domain.com/data.txt instead of domain.com/my_project/data.txt.


Solution

  • It sounds like you want to access the file here:

    <%= link_to "here", "/my_project/data.txt" %>