Download pdf with domain data

This commit is contained in:
Thiago Youssef 2022-06-28 10:24:35 -03:00
parent 8238b329e3
commit 318dec4f52
5 changed files with 331 additions and 3 deletions

View file

@ -2,7 +2,7 @@ module Admin
class DomainsController < BaseController
DEFAULT_VERSIONS_PER_PAGE = 10
before_action :set_domain, only: %i[show edit update keep]
before_action :set_domain, only: %i[show edit update download keep]
authorize_resource
# rubocop:disable Metrics/MethodLength
@ -65,6 +65,11 @@ module Admin
.per(DEFAULT_VERSIONS_PER_PAGE)
end
def download
filename = "#{@domain.name}.pdf"
send_data @domain.as_pdf, filename: filename
end
def keep
@domain.keep
redirect_to edit_admin_domain_url(@domain), notice: t('.kept')