Hi, I have been figthing unsuccessfuly with image for several days.
I am creating a report with Prawn, so in the header goes the logo of the company and its name.
def listing
@phones = Phone.all.order :phone
respond_to do |format|
format.pdf do
pdf = PhonePDF.new( view_context )
send_data pdf.render,
type: 'application/pdf',
disposition: 'inline'
end
end
end
Now I created:
app/pdf/phone.pdf.rb
This is the code for phone.pdf.rb:
require "open-uri"
class PhonePDF < Prawn::Document
def initialize( view )
@view = view
super size: :letter, margin: 56, layout: :portrait
# creating the page heading with: logo and brand name
table [ [ { image: open('/assets/logos/logo_officeya_67x100.png') }, 'officeya' ] ]
end
end
About the line in red:
I have try it like:
'assets/logos/logo_officeya_67x100.png'
'http://localhost:3000/assets/logos/logo_officeya_67x100.png'
'http://127.0.0.1:3000/assets/logos/logo_officeya_67x100.png'
And I get the same error:
it does not find the logo file, but, if I paste the last 2 lines in the browser, I get the logo.
Also I used 'http://lorempixel.com/30/30/' and, saddly, IT DID WORK!
Any idea what could be wrong. I do no want to use path relative to my file system.
Please help me before I ended pulling off all my hear.