2014-10-13 4 views
1

Gem =>https://github.com/galetahub/ckeditorRails CKEditor стрекоза Erorr

Rails = 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 

ответ

0

Удалить все инициализаторы 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...} 
0

Eraden, ваш пример работает. Я заменил содержимое ckeditor_dragonfly.rb тем, что вы дали, а затем «rake db: migrate» был, наконец, успешным.

Но тогда, когда я загрузить изображение я получаю:

NoMethodError (неопределенный метод ckeditor_file_accessor' for #<Class:0x007fb92c720118>): app/models/ckeditor/asset.rb:5:in ' приложения/модель/CKEditor/asset.rb: 1: в <top (required)>' app/models/ckeditor/picture.rb:1:in'

Кажется, что вам нужно замените «ckeditor_file_accessor: data» на «dragonfly_accessor: data» в /app/model/ckeditor/asset.rb. Это решило эту конкретную ошибку для меня, хотя вместо этого у меня есть другая, но она, похоже, не имеет ничего общего с обсуждаемая тема.

(только для случая, я напишу это p roblem здесь:

DRAGONFLY: не удалось выполнить проверку формата данных с ошибкой Ошибка отказа ('ident' '-ping' '-format' '% m% w% h' '/ var/folders/x6/pwnc5kls5d17z4j715t45jkr0000gr/T/RackMultipart20150406-2109-1ho7120 ') с статусом выхода и stderr dyld: библиотека не загружена: /usr/local/lib/liblzma.5.dylib Ссылка:/usr/local/bin/ident Причина: изображение не найдено

)

Смежные вопросы