【发布时间】:2014-10-01 08:02:28
【问题描述】:
我在所见即所得的编辑器 (ckeditor) 中上传内联图像。它与回形针集成。 但是,当我生成 pdf 时,来自 ckeditor 的图像不会出现。 我究竟做错了什么?
代码如下:
附件文件.rb:
class Ckeditor::AttachmentFile < Ckeditor::Asset
has_attached_file :data,
:url => "/ckeditor_assets/attachments/:id/:filename",
:path => ":rails_root/public/ckeditor_assets/attachments/:id/:filename"
validates_attachment_presence :data
validates_attachment_size :data, :less_than => 100.megabytes
do_not_validate_attachment_file_type :data
def url_thumb
@url_thumb ||= Ckeditor::Utils.filethumb(filename)
end
end
controller.rb:
def download
html = render_to_string("offer_template_one", :formats => [:html], :layout => "templates.html")
pdf = WickedPdf.new.pdf_from_string(html)
send_data(pdf,
:filename => "offer.#{@offer.id}.pdf",
:disposition => 'attachment')
end
应用程序.rb:
config.assets.paths << Rails.root.join("app", "assets", "fonts")
config.assets.precompile += %w( templates.css )
config.autoload_paths += %W(#{config.root}/app/models/ckeditor)
ckeditor里面上传的图片保存到public/ckeditor_assets/pictures中
谢谢!
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-4 ckeditor wicked-pdf