简体   繁体   中英

How to create a link in Sinatra that points to a directory of files?

I have an application that calls an other application that populates a directory. Once it is finished I want to provide a link to the directory that contains the created files and people can examine or download them via the browser:

For example this works to provide a link to a single file: (Note this uses HAML) but the idea is the same

%p
  - output_href = File.join("..","..","test_runs",File.basename(@dealclick_test_run.result_filename) )
  Result file =
  %a{:id => "result-file", :href => "#{output_href}"}
    = File.basename(@dealclick_test_run.result_filename)`

The corresponding code for the directory doesn't work:

 %p
    Results:
    - output_href = File.join("..","..","test_runs",File.basename(@dp_test_run.result_filename) )
   %a( id = "dealprocessor_results" href = "#{output_href}" )
    = File.basename(@dp_test_run.result_filename)

What am I doing wrong?

%a( id = "dealprocessor_results" href = "#{output_href}" )

应该

%a(:id = "dealprocessor_results" :href = "#{output_href}" )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM