首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >将Cloudinary、Carrierwave、Ckeditor与Rails Admin一起使用时出现问题

将Cloudinary、Carrierwave、Ckeditor与Rails Admin一起使用时出现问题
EN

Stack Overflow用户
提问于 2012-09-24 02:31:18
回答 2查看 1.1K关注 0票数 0

我正在尝试在Rails Admin中使用Ckeditor,其中我使用Carrierwave和云存储作为Cloudinary。在进行了我看到的所有设置之后,CKeditor可以将文件保存在本地存储上,然后它会创建一个Cloudinary URL,实际上应该在其中存储图像。但问题是图像没有从本地文件夹上传到Cloudinary,而我的简单文件上传工作正常,没有任何问题。

我这里还有一个问题--当我使用Cloudinary时,存储名称应该是什么?至于文件和亚马逊S3,我们有文件和s3的名称。

请回复。

谢谢

EN

回答 2

Stack Overflow用户

发布于 2018-06-09 03:29:04

我对ckeditor也有意见。编辑您的CkeditorAttachmentFileUploader,使其如下所示:

代码语言:javascript
复制
class CkeditorAttachmentFileUploader < CarrierWave::Uploader::Base
  include Ckeditor::Backend::CarrierWave
  include Cloudinary::CarrierWave

  [:extract_content_type, :extract_size, :extract_dimensions].each do |method|
    define_method :"#{method}_with_cloudinary" do
      send(:"#{method}_without_cloudinary") if self.file.is_a?(CarrierWave::SanitizedFile)
      {}
    end
    alias_method :"#{method}_without_cloudinary", method
    alias_method method, :"#{method}_with_cloudinary"
  end

  def extension_white_list
    Ckeditor.attachment_file_types
  end
end

在那之后,你会发现另一个错误。我发现在Ckeditor::AssetResponse#asset_url方法中,asset对象不会重新加载,因此asset.content_url将始终为空,从而导致错误。我是这样修复的:

代码语言:javascript
复制
class Ckeditor::Picture < Ckeditor::Asset
  ...
  def url_content
    url(:content) || begin
      if persisted?
        reload
        url(:content)
      end
    end
  end
end

如果你有Ckeditor::AttachmentFile类,它也是一样的。

票数 2
EN

Stack Overflow用户

发布于 2013-04-12 10:04:22

确保删除对CarrierWave.config.storage = :file的所有引用

如果上传不起作用,您需要在以下几个地方执行此操作:

在/config/initializers/carrierwave_init.rb中,删除对以下内容的所有引用:

代码语言:javascript
复制
config.storage = :file

在你的上传程序中删除和引用排序:

代码语言:javascript
复制
storage :file
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12555075

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档