Ruby on rails 在Rails4中下载公共文件
我正在使用Rails-4.0.2、ruby 2.1.0,并且有几个公共文件,它们在我的app/public文件夹中。在index.html视图中,我下载了以下表单Ruby on rails 在Rails4中下载公共文件,ruby-on-rails,ruby,nginx,download,Ruby On Rails,Ruby,Nginx,Download,我正在使用Rails-4.0.2、ruby 2.1.0,并且有几个公共文件,它们在我的app/public文件夹中。在index.html视图中,我下载了以下表单 <table class="table table-condensed table-striped" style="border-collapse: collapse; border-spacing: 0; width: 50%;"> <tbody> <% @reports.eac
<table class="table table-condensed table-striped" style="border-collapse: collapse;
border-spacing: 0; width: 50%;">
<tbody>
<% @reports.each do |report| %>
<tr>
<td><%= report.title %></td>
<td> <a href=<%= "#{report.url}"%>> Download </a></td>
</tr>
<% end %>
</tbody>
这只是公用文件夹中的静态文件,如何在生产中下载
以下是我的配置文件:
发展:
制作:
提前谢谢 该文件不会在生产中交付,因为
# Disable Rails's static asset server (Apache or nginx will already do this).
config.serve_static_assets = false
我建议您使用真正的Web服务器(如nginx或Apache)来交付静态文件!(作为配置nginx或Google的起点)
Started GET "/reports/2014-01-22-13:45:13-UTC.xlsx" for 127.0.0.1 at 2014-01-22 17:50:13 +0400
Processing by ReportsController#show as XLSX
Parameters: {"id"=>"2014-01-22-13:45:13-UTC"}
Completed 404 Not Found in 2ms
ActiveRecord::RecordNotFound (Couldn't find Report with
id=2014-01-22-13:45:13-UTC):
app/controllers/reports_controller.rb:60:in `set_report'
GetLead::Application.configure do
config.cache_classes = false
config.eager_load = true
config.serve_static_assets = true
config.assets.initialize_on_precompile = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = false
config.assets.compress = true
config.assets.compile = true
config.assets.digest = true
config.log_level = :info
config.i18n.fallbacks = true
config.active_support.deprecation = :notify
config.log_formatter = ::Logger::Formatter.new
end
GetLead::Application.configure do
config.cache_classes = true
config.eager_load = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.serve_static_assets = false
config.assets.compress = true
config.assets.compile = true
config.assets.digest = true
config.i18n.fallbacks = true
config.active_support.deprecation = :notify
end
# Disable Rails's static asset server (Apache or nginx will already do this).
config.serve_static_assets = false