我有这样Axlsx-Rails的宝石不能正常工作,显示缺少模板
<%= link_to "download file", import_horse_report_horses_path(format: 'xlsx') %>
一个链接,然后在控制器动作我有以下代码
def import_horse_report
@horses = ImportHorse.all
respond_to do |format|
format.xlsx{ }
end
end
对于这个动作我有这个模板import_horse_report.xlsx.axlsx
wb = xlsx_package.workbook
wb.add_worksheet(name: "Horses") do |sheet|
@horses.each do |horse|
sheet.add_row [horse.breed, horse.date_of_birth, horse.gender]
end
end
我使用axlsx_rails宝石并按照其文档。但我得到这个错误
Missing template horses/import_horse_report, application/import_horse_report with {:locale=>[:en], :formats=>[:xlsx], :handlers=>[:erb, :builder, :coffee, :rabl]}
我该如何解决这个问题?
您保存了这个'import_horse_report.xlsx.axlsx'模板的位置?路径? –
在这个控制器的其他动作的视图 – asdfkjasdfjk
让我的路径 –