2016-09-05 4 views
0

私はちょうど搬送波と曇りを含むckeditorで画像をアップロードする 私は一度試してみたところ、 ckeditorの画像アップローダー経由でcloudbeanにアップロードしてください。しかし、私が新しい記事を編集したり作成したりして画像をアップロードしようとすると、画像アップローダーはもう動作しません。私はなぜイメージアップローダーを作った後に何も編集しなかったのか分からない。誰でも私を助けることができますか? THXとにかくRAILS 5:ブラウズサーバCKEditorエラー '未定義のメソッド `パス' '画像をアップロードした後

この enter image description here

のように出てくる

エラーここに私のモデル/ CKEditorバージョン/ asset.rbだ

class Ckeditor::Asset < ActiveRecord::Base 

    include Ckeditor::Orm::ActiveRecord::AssetBase 
    delegate :url, :current_path, :content_type, to: :data 
    validates :data, presence: true 
end 

モデル/ CKEditorバージョン/ picture.rb

class Ckeditor::Picture < Ckeditor::Asset 
    mount_uploader :data, CkeditorPictureUploader, mount_on: :data_file_name 

    def url_content 
    url(:content) 
    end 
end 

モデル/ ckeditor/attachment_file.rb

class Ckeditor::AttachmentFile < Ckeditor::Asset 
    mount_uploader :data, CkeditorAttachmentFileUploader, mount_on: :data_file_name 

    def url_thumb 
    @url_thumb ||= Ckeditor::Utils.filethumb(filename) 
    end 
end 

アップローダー/ CKEditorバージョン/ ckeditor_picture_uploader.rb

class CkeditorPictureUploader < CarrierWave::Uploader::Base 
    include Ckeditor::Backend::CarrierWave 
    include Cloudinary::CarrierWave 
    include CarrierWave::MiniMagick 

    version :thumb do 
    process resize_to_fill: [118, 100] 
    end 

    version :content do 
    process resize_to_limit: [800, 800] 
    end 

def extension_white_list 
    Ckeditor.image_file_types 
    end 
end 

設定/初期化子/ ckeditor.rb

Ckeditor.setup do |config| 
    # ==> ORM configuration 
    # Load and configure the ORM. Supports :active_record (default), :mongo_mapper and 
    # :mongoid (bson_ext recommended) by default. Other ORMs may be 
    # available as additional gems. 
    require "ckeditor/orm/active_record" 
config.picture_model { Ckeditor::Picture } 
    # config.attachment_file_model { Ckeditor::AttachmentFile } 

    Rails.application.config.assets.precompile += %w(ckeditor/filebrowser/images/gal_del.png) 

    config.cdn_url = "//cdn.ckeditor.com/4.5.6/standard/ckeditor.js" 

    config.js_config_url = "/assets/ckeditor/config.js" 
end 

EDIT

は、ここに私のCKEditorバージョンのjs CKEditorバージョン/ config.jsの

です
CKEDITOR.editorConfig = function(config) 
{ 
    config.enterMode = 2 
    config.filebrowserBrowseUrl = "/ckeditor/attachment_files"; 
    config.filebrowserFlashBrowseUrl = "/ckeditor/attachment_files"; 
    config.filebrowserFlashUploadUrl = "/ckeditor/attachment_files"; 
    config.filebrowserImageBrowseLinkUrl = "/ckeditor/pictures"; 
    config.filebrowserImageBrowseUrl = "/ckeditor/pictures"; 
    config.filebrowserImageUploadUrl = "/ckeditor/pictures"; 
    config.filebrowserUploadUrl = "/ckeditor/attachment_files"; 
    config.toolbar_Pure = [ 
    '/', { 
     name: 'basicstyles', 
     items: ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat'] 
    }, { 
     name: 'paragraph', 
     items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl'] 
    }, { 
     name: 'links', 
     items: ['Link', 'Unlink'] 
    }, '/', { 
     name: 'styles', 
     items: ['Styles', 'Format', 'Font', 'FontSize'] 
    }, { 
     name: 'colors', 
     items: ['TextColor', 'BGColor'] 
    }, { 
     name: 'insert', 
     items: ['Image', 'Table', 'HorizontalRule', 'PageBreak'] 
    } 
    ]; 

    config.allowedContent = true; 
    config.toolbar = 'Pure'; 
    return true; 
} 

答えて

0
[: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 

チェックCKEditor Carrierwave Cloudinary

関連する問題