【问题标题】:Rails ckeditor dragonfly ErorrRails ckeditor蜻蜓错误
【发布时间】:2014-10-13 11:19:02
【问题描述】:

宝石 => https://github.com/galetahub/ckeditor

导轨 = 4.1.4

我已经完成了

rails generate ckeditor:install --orm=active_record --backend=dragonfly

ckeditor_dragonfly.rb

# Load Dragonfly for Rails if it isn't loaded already.
require "dragonfly/rails/images"

# Use a separate Dragonfly "app" for CKEditor.
app = Dragonfly[:ckeditor]
app.configure_with(:rails)
app.configure_with(:imagemagick)

# Define the ckeditor_file_accessor macro.
app.define_macro(ActiveRecord::Base, :ckeditor_file_accessor) if defined?(ActiveRecord::Base)
app.define_macro_on_include(Mongoid::Document, :ckeditor_file_accessor) if defined?(Mongoid::Document)

app.configure do |c|
  # Store files in public/uploads/ckeditor. This is not
  # mandatory and the files don't even have to be stored under
  # public. If not storing under public then set server_root to nil.
  c.datastore.root_path = Rails.root.join("public", "uploads", "ckeditor", Rails.env).to_s
  c.datastore.server_root = Rails.root.join("public").to_s

  # Accept asset requests on /ckeditor_assets. Again, this is not
  # mandatory. Just be sure to include :job somewhere.
  c.url_format = "/uploads/ckeditor/:job/:basename.:format"
end

# Insert our Dragonfly "app" into the stack.
Rails.application.middleware.insert_after Rack::Cache, Dragonfly::Middleware, :ckeditor

但是当我尝试做某事时,一个错误:

Dragonfly::App[:ckeditor] is deprecated - use Dragonfly.app (for the default app) or Dragonfly.app(:ckeditor) (for extra named apps) instead. See docs at http://markevans.github.io/dragonfly for details

NoMethodError: undefined method `configure_with' for Dragonfly:Module

有什么想法可以解决这个问题?

UPD。如果更正这些错误,则变为:

Dragonfly::Configurable::UnregisteredPlugin: plugin :rails is not registered

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-4 ckeditor dragonfly-gem


    【解决方案1】:

    删除所有 ckeditor 初始化器。

    添加具有以下内容的新文件:

    require 'dragonfly'
    
    # Logger
    Dragonfly.logger = Rails.logger
    
    # Add model functionality
    if defined?(ActiveRecord::Base)
      ActiveRecord::Base.extend Dragonfly::Model
      ActiveRecord::Base.extend Dragonfly::Model::Validations
    end
    
    Dragonfly.app(:ckeditor).configure do
    
      # this generate path like this:
      # /uploads/ckeditor/AhbB1sHOgZmIjIyMDEyLzExLzIzLzE3XzIxXzAwXzY0OF9zdXJ2ZWlsbGFuY2VfbmNjbi5wbmdbCDoGcDoKdGh1bWJJI.something.png
      url_format '/uploads/ckeditor/:job/:basename.:format'
    
      # some image from previous version can break without this
      verify_urls false
      plugin :imagemagick
    
      # required if you want use paths from previous version
      allow_legacy_urls true
    
      # "secure" if images needs this
      secret 'ce649ceaaa953967035b113647ba56db19fd263fc2af77737bae09d452ad769d'
    
      datastore :file,
                root_path: Rails.root.join('public', 'system','uploads', 'ckeditor', Rails.env),
                server_root: Rails.root.join('public')
    end
    
    Rails.application.middleware.use Dragonfly::Middleware, :ckeditor
    

    这将以(旧样式)存储图像:

    {Rails.root}/public/system/uploads/ckeditor/{development,production,etc...}
    

    【讨论】:

      【解决方案2】:

      Eraden,您的示例有效。我已经用您提供的内容替换了 ckeditor_dragonfly.rb 的内容,然后“rake db:migrate”终于成功了。

      但是当我上传图片时,我得到:

      NoMethodError (未定义方法ckeditor_file_accessor' for #<Class:0x007fb92c720118>): app/models/ckeditor/asset.rb:5:in' app/models/ckeditor/asset.rb:1:in <top (required)>' app/models/ckeditor/picture.rb:1:in'

      看来,您需要将 /app/model/ckeditor/asset.rb 中的“ckeditor_file_accessor :data”替换为“dragonfly_accessor :data”。这为我解决了这个特殊错误,虽然我有另一个错误,但它似乎与讨论的主题无关。

      (只是为了这种情况,我把这个问题写在这里:

      DRAGONFLY:数据的属性格式验证失败并出现错误命令失败('identify''-ping''-format''%m %w %h''/var/folders/x6/pwnc5kls5d17z4j715t45jkr0000gr/T/RackMultipart20150406- 2109-1ho7120') 具有退出状态和 stderr dyld:未加载库:/usr/local/lib/liblzma.5.dylib 引用自:/usr/local/bin/identify 原因:找不到图片

      )

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-10-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-04-14
        • 2012-07-06
        • 1970-01-01
        相关资源
        最近更新 更多