如何在活动管理员中将格式传递给自定义页面的页面操作?

时间:2019-03-24 07:35:38

标签: ruby-on-rails activeadmin wicked-pdf presenter custom-pages

我正在使用Active Admin设置自定义页面。要求是显示公司在选定月份中生成的所有报告。我已经通过公司展示页面中的按钮链接到报告页面。 “每月报告”是一个自定义页面,其表单包含一个HTML 5个月选择器作为内容。提交表单时,我该在哪里传递PDF之类的格式来下载PDF?

我对渲染PDF还有另一个疑问。我在显示特定PDF时正在使用演示者。在这种情况下,我必须渲染/合并多个PDF。我为此使用了邪恶的PDF gem,并遍历所有报告以在monthly_report.pdf.haml文件中呈现多个报告。您是否有利用演示者来合并/渲染PDF的想法?

我还必须将活动管理员日期选择器的主题用于月选择器,而不是HTML月选择器。

当前代码如下:- admin / companies.rb

  action_item :montly_reports, only: :show do
    link_to 'Monthly Reports', admin_company_monthly_reports_path(company_id: company.id)
  end

admin / monthly_reports.rb

# frozen_string_literal: true

ActiveAdmin.register_page 'Monthly Reports' do
  belongs_to :company

  page_action :export_pdf, method: :get do
    respond_to do |format|
      format.html
      format.pdf do
        //code for pdf goes here
      end
    end
  end

  content do
    form action: 'monthly_reports/export_pdf(format: :pdf)', method: :get do |f|
      f.input :date, type: :month, name: 'date'
      f.input :submit, type: :submit
    end
  end
end

也做了“ monthly_reports / export_pdf.pdf”

预期结果:必须呈现所选月份内所选公司生成的所有报告的PDF。

0 个答案:

没有答案
相关问题