I want to show a header image in the attached pdf. I'm using the wicked_pdf_asset_pack_path as follows:
estimation_pdf.html.erb
<%= image_tag(wicked_pdf_asset_pack_path("media/images/header_lighuen.png"), width: "600", height: "120") %>
This is working if a download the pdf directly, but it doesn't in the attached file at the mail.
estimation_mailer.rb
class EstimationMailer < ApplicationMailer
helper ApplicationHelper
def new_estimation_email
@estimation = params[:estimation]
# Attach the Lighuen logo
attachments.inline["encabezado_email.jpg"] = File.read("#{Rails.root}/app/assets/images/encabezado_email.jpg")
attachments["Presupuesto "[email protected]_at.strftime("%d/%m/%Y")+".pdf"] = WickedPdf.new.pdf_from_string(
render_to_string(
:template => 'shared/estimation_pdf.html.erb',
page_size: 'A4',
layout: 'light_pdf.html',
encoding: 'UTF-8',
disable_smart_shrinking: true,
viewport_size: '1920x1080',
margin: {
top: 10, # default 10 (mm)
bottom: 10,
left: 5,
right: 5
}
)
)
mail(to: "#{@estimation.client_email}", subject: "Presupuesto "[email protected]+" "[email protected]_at.strftime("%d/%m/%Y"))
end
end
This happens when i send the mail:
The image's path is: app/javascript/images/header_lighuen.png
Console output:
Started GET "/rails/active_storage/disk/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdDVG9JYTJWNVNTSnJkbUZ5YVdGdWRITXZOM1kyYjNGdmJuQm5lR1YxZFdwek1tOXJZVEIxWlRscWFqUm1iaTgzTmpjd1lqQTVabVUxTkdOaFpUUXdNbVZsTm1GbVpEZG1NR1JqT1RaaE5EVmlOV013WXpjNFlqQTRaRFJrT1RsbFpUVmtOamcwTldVMU5EUmpZVEl4QmpvR1JWUTZFR1JwYzNCdmMybDBhVzl1U1NKbmFXNXNhVzVsT3lCbWFXeGxibUZ0WlQwaWQyRnNiR2hoZG1WdUxUazJOM3A1YTE4eE1qZ3dlREV3TWpRdWNHNW5JanNnWm1sc1pXNWhiV1VxUFZWVVJpMDRKeWQzWVd4c2FHRjJaVzR0T1RZM2VubHJYekV5T0RCNE1UQXlOQzV3Ym1jR093WlVPaEZqYjI1MFpXNTBYM1I1Y0dVaURtbHRZV2RsTDNCdVp6b1JjMlZ5ZG1salpWOXVZVzFsT2dwc2IyTmhiQT09IiwiZXhwIjoiMjAyMS0wMS0yNVQxNDowMTo1NS4xODNaIiwicHVyIjoiYmxvYl9rZXkifX0=--edb302b486ccd7687ec5a3f0f0611fcee054091d/wallhaven-967zyk_1280x1024.png" for ::1 at 2021-01-25 10:56:55 -0300
Processing by ActiveStorage::DiskController#show as PNG
Parameters: {"encoded_key"=>"[FILTERED]", "filename"=>"wallhaven-967zyk_1280x1024"}
Completed 200 OK in 1ms (ActiveRecord: 0.0ms | Allocations: 460)
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] DEPRECATION WARNING: Rendering actions with '.' in the name is deprecated: shared/estimation_pdf.html.erb (called from new_estimation_email at /home/bashud/Documentos/APPS/vitromanage/app/mailers/estimation_mailer.rb:12)
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] DEPRECATION WARNING: Rendering actions with '.' in the name is deprecated: layouts/light_pdf.html (called from new_estimation_email at /home/bashud/Documentos/APPS/vitromanage/app/mailers/estimation_mailer.rb:12)
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] Rendering layout layouts/light_pdf.html.erb
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] Rendering shared/estimation_pdf.html.erb within layouts/light_pdf.html
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] Client Load (0.8ms) SELECT "clients".* FROM "clients" WHERE "clients"."deleted_at" IS NULL AND "clients"."id" = $1 LIMIT $2 [["id", 8], ["LIMIT", 1]]
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] ? app/models/estimation.rb:52:in `client_full_name'
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] Location Load (0.4ms) SELECT "locations".* FROM "locations" WHERE "locations"."id" = $1 LIMIT $2 [["id", 9], ["LIMIT", 1]]
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] ? app/models/estimation.rb:53:in `location_name'
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] [Webpacker] Everything's up-to-date. Nothing to do
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] EstimationSupply Load (0.9ms) SELECT "estimation_supplies".* FROM "estimation_supplies" WHERE "estimation_supplies"."deleted_at" IS NULL AND "estimation_supplies"."estimation_id" = $1 ORDER BY "estimation_supplies"."position" DESC [["estimation_id", 108]]
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] ? app/models/estimation.rb:173:in `has_tvh?'
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] Supply Load (0.4ms) SELECT "supplies".* FROM "supplies" WHERE "supplies"."id" = $1 LIMIT $2 [["id", 5], ["LIMIT", 1]]
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] ? app/models/estimation_supply.rb:62:in `is_tvh?'
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] Supply Load (0.3ms) SELECT "supplies".* FROM "supplies" WHERE "supplies"."id" = $1 LIMIT $2 [["id", 11], ["LIMIT", 1]]
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] ? app/models/estimation_supply.rb:62:in `is_tvh?'
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] EstimationSupply Load (0.5ms) SELECT "estimation_supplies".* FROM "estimation_supplies" WHERE "estimation_supplies"."deleted_at" IS NULL AND "estimation_supplies"."estimation_id" = $1 ORDER BY "estimation_supplies"."position" ASC [["estimation_id", 108]]
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] ? app/views/shared/estimation_pdf.html.erb:51
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] CACHE Supply Load (0.0ms) SELECT "supplies".* FROM "supplies" WHERE "supplies"."id" = $1 LIMIT $2 [["id", 11], ["LIMIT", 1]]
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] ? app/models/estimation_supply.rb:42:in `supply_name'
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] Category Load (0.6ms) SELECT "categories".* FROM "categories" INNER JOIN "categories_supplies" ON "categories"."id" = "categories_supplies"."category_id" WHERE "categories_supplies"."supply_id" = $1 [["supply_id", 11]]
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] ? app/models/supply.rb:106:in `is_special?'
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] CACHE Supply Load (0.0ms) SELECT "supplies".* FROM "supplies" WHERE "supplies"."id" = $1 LIMIT $2 [["id", 5], ["LIMIT", 1]]
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] ? app/models/estimation_supply.rb:42:in `supply_name'
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] Category Load (0.5ms) SELECT "categories".* FROM "categories" INNER JOIN "categories_supplies" ON "categories"."id" = "categories_supplies"."category_id" WHERE "categories_supplies"."supply_id" = $1 [["supply_id", 5]]
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] ? app/models/supply.rb:106:in `is_special?'
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] VariableConfiguration Load (0.6ms) SELECT "variable_configurations".* FROM "variable_configurations" WHERE "variable_configurations"."status" = $1 ORDER BY "variable_configurations"."id" ASC LIMIT $2 [["status", 1], ["LIMIT", 1]]
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] ? app/views/shared/estimation_pdf.html.erb:110
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] Rendered shared/estimation_pdf.html.erb within layouts/light_pdf.html (Duration: 34.4ms | Allocations: 13643)
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] Rendered layout layouts/light_pdf.html.erb (Duration: 39.4ms | Allocations: 16971)
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] [wicked_pdf]: ["/home/bashud/.rvm/gems/ruby-3.0.0@vitromanage/gems/wkhtmltopdf-binary-0.12.6.5/bin/wkhtmltopdf", "file:////tmp/wicked_pdf20210125-25050-pk6m75.html", "/tmp/wicked_pdf_generated_file20210125-25050-8bz04n.pdf"]
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] Rendering layout layouts/mailer.html.erb
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] Rendering estimation_mailer/new_estimation_email.html.erb within layouts/mailer
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] Rendered estimation_mailer/new_estimation_email.html.erb within layouts/mailer (Duration: 8.3ms | Allocations: 7391)
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] Rendered layout layouts/mailer.html.erb (Duration: 9.0ms | Allocations: 7585)
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] Rendering layout layouts/mailer.text.erb
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] Rendering estimation_mailer/new_estimation_email.text.erb within layouts/mailer
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] Rendered estimation_mailer/new_estimation_email.text.erb within layouts/mailer (Duration: 0.5ms | Allocations: 183)
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] Rendered layout layouts/mailer.text.erb (Duration: 0.9ms | Allocations: 356)
[ActiveJob] [ActionMailer::Parameterized::DeliveryJob] [c25de849-6098-4691-a5fa-b7ec71bfa3b0] EstimationMailer#new_estimation_email: processed outbound mail in 1566.9ms