CK编辑器图像上传在使用rails 5 app + carrierwave的生产中无效

时间:2018-02-02 09:59:38

标签: ruby-on-rails ckeditor image-uploading

我正在使用CK编辑器,在部署之后我无法上传任何图像,但它正在开发中。我收到此错误“图像源网址丢失”,这是我的config.js文件:

我发现很多人都有同样的错误,但没有人回答为什么会发生这种情况所以我应该迁移到另一个编辑器还是什么?!

config.js

I, [2018-02-02T12:48:12.886841 #16570]  INFO -- : [5a150ff6-afb3-4f98-a1cb-c954703b971d]   Parameters: {"upload"=>#<ActionDispatch::Http::UploadedFile:0x00007f51110b4668 @tempfile=#<Tempfile:/tmp/RackMultipart20180202-16570-1g62x7e.jpg>, @original_filename="ibrahim.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"upload\"; filename=\"ibrahim.jpg\"\r\nContent-Type: image/jpeg\r\n">, "ckCsrfToken"=>"7n2JrWACJV1ceGDYnu1SUaY1p9iWr0Q4P0b40nQv", "CKEditor"=>"post_content", "CKEditorFuncNum"=>"1", "langCode"=>"en"}
    I, [2018-02-02T12:48:12.892512 #16570]  INFO -- : [5a150ff6-afb3-4f98-a1cb-c954703b971d] Completed 401 Unauthorized in 6ms (ActiveRecord: 0.0ms)
    F, [2018-02-02T12:48:12.895003 #16570] FATAL -- : [5a150ff6-afb3-4f98-a1cb-c954703b971d]
    F, [2018-02-02T12:48:12.895093 #16570] FATAL -- : [5a150ff6-afb3-4f98-a1cb-c954703b971d] MiniMagick::Error (ImageMagick/GraphicsMagick is not installed):
    F, [2018-02-02T12:48:12.895128 #16570] FATAL -- : [5a150ff6-afb3-4f98-a1cb-c954703b971d]
    F, [2018-02-02T12:48:12.895216 #16570] FATAL -- : [5a150ff6-afb3-4f98-a1cb-c954703b971d] mini_magick (4.8.0) lib/mini_magick/configuration.rb:127:in `cli'
    [5a150ff6-afb3-4f98-a1cb-c954703b971d] mini_magick (4.8.0) lib/mini_magick.rb:38:in `graphicsmagick?'
    [5a150ff6-afb3-4f98-a1cb-c954703b971d] mini_magick (4.8.0) lib/mini_magick/tool.rb:126:in `executable'
    [5a150ff6-afb3-4f98-a1cb-c954703b971d] mini_magick (4.8.0) lib/mini_magick/tool.rb:110:in `command'

1 个答案:

答案 0 :(得分:0)

那么,您可以上传图像并进行检查,看看它在哪里吗?他可能正在查看一个文件夹,你可以在其他地方寻找。你是否在生产模式下预编译了资产?

我在我的应用中有这个配置:

/* Filebrowser routes */
// The location of an external file browser, that should be launched when "Browse Server" button is pressed.
config.filebrowserBrowseUrl = "/ckeditor/attachment_files";

// The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Flash dialog.
config.filebrowserFlashBrowseUrl = "/ckeditor/attachment_files";

// The location of a script that handles file uploads in the Flash dialog.
config.filebrowserFlashUploadUrl = "/ckeditor/attachment_files";

// The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Link tab of Image dialog.
config.filebrowserImageBrowseLinkUrl = "/ckeditor/pictures";

// The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Image dialog.
config.filebrowserImageBrowseUrl = "/ckeditor/pictures";

// The location of a script that handles file uploads in the Image dialog.
config.filebrowserImageUploadUrl = "/ckeditor/pictures";

// The location of a script that handles file uploads.
config.filebrowserUploadUrl = "/ckeditor/attachment_files";

在你的config / initializers / ckeditor中,你取消注释了吗?在你的config / application.rb中,你有没有这样的东西?

config.assets.precompile += Ckeditor.assets
    config.assets.precompile += %w( ckeditor/* ckeditor_assets/* *.png *.jpg *.jpeg *.gif img/*)
    config.encoding = "utf-8"
    config.assets.paths << "#{Rails}/vendor/assets/*"
    config.autoload_paths += %w(#{config.root}/app/models/ckeditor)

那么,你能发布更多细节吗?您使用哪个上传载波或回形针或其他东西?