【问题标题】:Ckeditor 3.7.1 + Paperclip (Absolute Paths in Email)Ckeditor 3.7.1 + Paperclip(电子邮件中的绝对路径)
【发布时间】:2012-06-19 20:04:26
【问题描述】:

我按照 github (https://github.com) 上发布的说明在 Rails 3.2.3 中安装了 ckeditor 3.7.1 和 Paperclip gems (gem 'ckeditor', '3.7.1' gem 'paperclip') /galetahub/ckeditor)。这一切似乎都在工作,除了当我尝试使用从 ckeditor 生成的 html(包含上传的图像)向 AccountMailer 发送电子邮件时,它给了我这个:

<img alt=3D"logo" src=3D"/assets/logo= .png" />

当我想要这个时:

<img alt=3D"logo" src=3D"www.mydomain.com/assets/logo= .png" />

我发现文档非常混乱,并且 gem 不提供对 config.js 的访问以修改 baseHref。我已经尝试更改模型/ckeditor 中的 attachment_file.rb 和 picture.rb 以使 url 包含域,但这会破坏上传功能。我也尝试过 ckeditor_rails 但这会删除上传功能,我没有时间 创建自定义浏览器和上传器。

感谢任何帮助。谢谢!

【问题讨论】:

  • 我最终在发送电子邮件之前将它们全部替换了。 while !the_html.sub!(/\"\/ckeditor_assets\//, "\"#{DOMAIN_NAME}/ckeditor_assets/").nil? do end我仍然对更好的方法感到好奇。谢谢!

标签: paperclip ckeditor ruby-on-rails-3.2 email-attachments image-upload


【解决方案1】:

在你的 Ckeditor::Picture Model 中添加函数

  def url_content
    if Rails.env.production?
        host_url="http://your_domen"
     else
        host_url="http://localhost:3000"
     end
    host_url+url(:content)
  end

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-08-23
    • 2013-01-10
    • 2020-08-03
    • 1970-01-01
    • 2013-02-19
    • 2012-11-01
    • 1970-01-01
    • 2019-07-04
    相关资源
    最近更新 更多