Ankur Kumar
2014-Jan-30 20:05 UTC
Not able to save PDF Kit file to a Paperclip attachment in Rails 3.2.15
I am trying to save a pdf file (generated using Rails PDFKit gem) to a
paperclip attachment. The MySQL table entry shows following for the
paperclip attachment after saving the generated PDF file:
*MySQL table record:*
*************
id | resume_type | resume_attachment_file_name | resume_attachment_content_type
| resume_attachment_file_size | resume_attachment_updated_at
*1 | pdf | !ruby/object:File {} | NULL | NULL | NULL |*
**************
as against expected value to be something like in this format:
*resume.pdf | application/pdf | 38375 | 2014-01-30 18:24:34*
****************
Can someone please tell me what's going wrong here?
*Controller:*
html = render_to_string('resume.html.erb',layout: false)
kit = PDFKit.new(html, :page_size => 'Letter')
file_name = "resume"
path = "#{Rails.root}/app/assets/PDF/" + file_name.to_s +
".pdf"**file** = kit.to_file(path)
document = Document.new(:resume_type=>"pdf")
document.resume_attachment_file_name = **file**
document.save!
*schema.rb*
create_table "documents", :force => true do |t|
t.string "resume_type"
t.string "resume_attachment_file_name"
t.string "resume_attachment_content_type"
t.integer "resume_attachment_file_size"
t.datetime "resume_attachment_updated_at"
Thanks.
Regards,
Ankur
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/CALSL1eP1aKYATxRHti7ZLSYaxeM0M5fTX36iaHHoE0k%3DAezFDA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.