你好,我使用axlsx制作带有导轨的图形,但是我遇到了问题。
我遇到此错误“,显示#3行的/var/www/redmine-3.4.2/app/views/attachments/indicateur.html.erb:
#<#:0x0056430f1b8750>的未定义方法`attachments_path' 你的意思是?附件路径 attachments_path_url”
如果有人有主意,我就是接受者。谢谢
the controller(attachments_controller.rb
class AttachmentsController < ApplicationController
before_action :find_attachment, :only => [:show, :download, :thumbnail,
:update, :destroy]
before_action :find_editable_attachments, :only => [:edit_all, :update_all]
before_action :file_readable, :read_authorize, :only => [:show, :download,
:thumbnail]
before_action :update_authorize, :only => :update
before_action :delete_authorize, :only => :destroy
before_action :authorize_global, :only => :upload
# Disable check for same origin requests for JS files, i.e. attachments with
# MIME type text/javascript.
skip_after_action :verify_same_origin_request, :only => :download
accept_api_auth :show, :download, :thumbnail, :upload, :update, :destroy
def indicateur
@attachments=Attachment.all
respond_to do |format|
format.html
format.xlsx
end
end
end
indicateur.xlsx.axlsx
wb = xlsx_package.workbook
wb.add_worksheet(name: "Attachments") do |sheet|
@attachments.each do |attachment|
sheet.add_row [attachment.id, attachment.filename]
end
end
indicateur.html.erb
<h1>Indicateur</h1>
<%= link_to 'Download as .xlsx', attachments_path(format: :xlsx) %>