0
我有一個使用ckeditor和cloudinary的rails 4項目。該uplaod到Cloudinary工作正常,但上傳後,在編輯器應該小夥子的形象,我得到的錯誤:Rails4:CKEditor gsub錯誤
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
當我去上傳並點擊「在服務器上查找圖像」時,圖像就在那裏,我可以在編輯器上加載圖像,但不能在將圖像上傳到服務器時使用
之前有人遇到過這個問題?
謝謝!
謝謝!沒有lib/ckeditor文件夾。我應該創建一個? –
我剛剛嘗試創建文件:libs/ckeditor/asset_response.rb並將代碼放在那裏。但我仍然遇到同樣的錯誤。我沒有在我的項目中找到gem的CKEDITOR文件夾,所以我認爲我應該在我的項目的LIB文件夾中創建這個文件? –
是的,您必須在'lib' ckeditor/asset_response.rb文件中創建文件夾,並檢查模型中是否存在ckeditor文件夾。 –