当我使用paperclip从ckeditor上传图像时,我的控制台日志会进入无限循环,最后会显示消息
@extensions=["jpeg", "jpg", "jpe"]>] from Extension), content type discovered from file command: . See documentation to allow this combination.
我可以使用paperclip v3并从picture.rb中删除'validates_attachment_content_type'来解决这个问题。
但我不想为图片禁用内容类型验证。
答案 0 :(得分:1)
我们在CKEditor
中使用Paperclip
Rails 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
上次检查时效果很好: