Initial commit
This commit is contained in:
28
app/controllers/contract_templates/qr_codes_controller.rb
Normal file
28
app/controllers/contract_templates/qr_codes_controller.rb
Normal file
@@ -0,0 +1,28 @@
|
||||
class ContractTemplates::QrCodesController < ApplicationController
|
||||
before_action :set_contract_template
|
||||
|
||||
def show
|
||||
send_file qr_code.to_png, download_attributes
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def contract_templates
|
||||
policy_scope(ContractTemplate)
|
||||
end
|
||||
|
||||
def set_contract_template
|
||||
@contract_template = contract_templates.find(params[:contract_template_id])
|
||||
end
|
||||
|
||||
def qr_code
|
||||
authorize QrCode.build_from_contract_template(@contract_template)
|
||||
end
|
||||
|
||||
def download_attributes
|
||||
{
|
||||
filename: qr_code.filename,
|
||||
type: "image/png",
|
||||
}
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user