2015-12-12 96 views
2

當我用回形針的CKEditor上傳一張圖片,我的控制檯日誌趨於無窮循環,最終它顯示消息回形針,CKEditor的validates_attachment_content_type錯誤

@extensions=["jpeg", "jpg", "jpe"]>] from Extension), content type discovered from file command: . See documentation to allow this combination. 

我可以用曲別針V3和刪除「解決此來自picture.rb的validates_attachment_content_type'。

但我不想禁用圖片的內容類型驗證。

  • 操作系統:Windows 10
  • 的Rails:4.1.8
  • 紅寶石:2.1.5
  • 回形針:4.3.2
  • CKEDITOR:4.1.5
+1

,你能否證實[你'file'安裝在系統上(https://github.com/thoughtbot/paperclip#file) ,並在你的PATH var? –

+1

O,謝謝,它解決了我的問題 –

回答

1

我們使用CKEditorPaperclipRails 4.2.5使用以下模型(也許它會幫助你):

#app/models/ckeditor/asset.rb 
class Ckeditor::Asset < ActiveRecord::Base 
    include Ckeditor::Orm::ActiveRecord::AssetBase 
    include Ckeditor::Backend::Paperclip 

    ##### Custom stuff here ##### 
end 

#app/models/ckeditor/picture.rb 
class Ckeditor::Picture < Ckeditor::Asset 

    #Original 
    ############ 
    has_attached_file :data, 
        :url => "/ckeditor_assets/pictures/:id/:style_:basename.:extension", 
        :path => ":rails_root/public/ckeditor_assets/pictures/:id/:style_:basename.:extension", 
        :styles => { :content => '800>', :thumb => '118x100#' } 

    validates_attachment_presence  :data 
    validates_attachment_size   :data, :less_than => 5.megabytes 
    validates_attachment_content_type :data, :content_type => /\Aimage/ 

    def url_content 
    url(:content) 
    end 
end 

它運作良好我最後一次檢查:

enter image description here