【发布时间】:2017-04-10 17:33:57
【问题描述】:
我在 rails 4 中有一个项目,它使用 ckeditor 和 cloudinary。上传到 Cloudinary 工作正常,但上传后,当编辑器应该加载图像时,我收到错误:
NoMethodError - undefined method `gsub' for nil:NilClass:
我的 CKEditor 图片上传器是:
# encoding: utf-8
class CkeditorPictureUploader < CarrierWave::Uploader::Base
include Ckeditor::Backend::CarrierWave
include Cloudinary::CarrierWave
include CarrierWave::MiniMagick
[:extract_content_type, :set_size, :read_dimensions].each do |method|
define_method :"#{method}_with_cloudinary" do
send(:"#{method}_without_cloudinary") if self.file.is_a?(CarrierWave::SanitizedFile)
{}
end
alias_method_chain method, :cloudinary
end
process :read_dimensions
# Create different versions of your uploaded files:
version :thumb do
process :resize_to_fill => [118, 100]
end
version :content do
process :resize_to_limit => [800, 800]
end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_white_list
Ckeditor.image_file_types
end
end
当我去上传并点击“在服务器上查找图像”时,图像就在那里,我可以在编辑器上加载图像,但当我将图像上传到服务器时却不行
以前有人遇到过这个问题吗?
谢谢!
【问题讨论】:
标签: ruby-on-rails ruby ruby-on-rails-4 ckeditor gsub