I fear the following problem. I try to show a list of files that are hosted on the server. The files are hosted in / home / drakmond / Practicas / Yipi / logsLoader and with extension .txt.
The driver code is as follows:
class Admin::LogsController < AdminController
Directorio = "/home/drakmond/Practicas/Yipi/logsLoader"
def listar_archivos
@archivos = Dir.entries(Directorio)
send_file "#{Rails.root}/logsLoader/#{params[:file_name]}"
end
end
And the code of my view is:
<section class="content-header">
<h1><%= t('top_menu.logs')%></h1>
<ol class="breadcrumb">
<li><a href="<%= admin_dashboard_path %>"><i class="fa fa-dashboard"></i> <%= t('breadcrumb.home')%></a></li>
<li><a href="<%= admin_yipi_devices_path %>"><%= t('device.index.head')%></a></li>
<li class="active"><%= t('top_menu.logs')%></li>
</ol>
</section>
<section class='content'>
<div class='row'>
<div class="col-xs-12">
<div class="box box-warning">
<div class="box-header with-border">
<ul>
<% @archivos.each do |a| %>
<% if a == "." or a == ".." then next end; %>
<li>
<strong> <%= a %> </strong> |
<%= link_to "Descargar", admin_logs_listar_archivos_path, :action => :listar_archivos, :file_name => a %>|
</li>
<% end %>
</ul>
</div>
</div>
</div>
</div>
</section>
But with that the system shows me the following error:
Cannot read file /home/drakmond/Practicas/Yipi/logsLoader/
Does anyone know what I'm doing wrong?