title: How to download a file from rails application
body: <p>I can't seem to find a simple and clear answer to this problem anywhere! Everything seems either outdated or incomplete!</p>
  
  <p>I just want the user to be able to click on a link or button and download a file (that is somewhere in the public folder)</p>
  
  <p>I tried this:</p>
  
  <pre><code>#view
  &lt;%= link_to "Raw blast output" ,:action =&gt; :download, :file_name =&gt; "public/data/02_blastout/#{@bl_file}" %&gt;
  #controller
  def download
      send_file "#{RAILS_ROOT}/#{params[:file_name]}"
  end
  </code></pre>
  
  <p>but I get this error:</p>
  
  <pre><code>No route matches {:action=&gt;"download", :file_name=&gt;"public/data/02_blastout/input0.fa_x_Glyma1aaunq.bl", :controller=&gt;"cvits"}
  </code></pre>
  
  <p>Thanks for the help!!</p>