2014-12-03 3 views
0

왜 ImageMagick에서 내 Paperclip 업로드를 열 수 있습니까?Paperclip 및 RMagick :이 이미지 형식의 디코딩 대리자가 없습니다.

몇 가지 검사를 수행 할 수 있어야합니다.

class Photo < ActiveRecord::Base 
    ATTACHMENT_STYLES = lambda do |attachment| 
    if is_something?(attachment.instance) 
     ... 
    else 
     ... 
    end 
    end 
    ATTACHMENT_PROCESSORS = lambda { |attachment| is_something?(attachment.instance) ? [:other_processor] : [:thumbnail] } 

    ... 

    def self.is_something?(attachment) 
    file = Magick::ImageList.new(attachment) 

    ... 
    end 
end 

하지만 왜 내가 이것을 얻고 있습니까?

Magick::ImageMagickError in TopicsController#create 
no decode delegate for this image format `0x00000004e3cc50>' @ error/constitute.c/ReadImage/544 
Extracted source (around line #20): 
file = Magick::ImageList.new(attachment) 

app/models/photo.rb:20:in `new' 
app/models/photo.rb:20:in `is_something?' 
app/models/photo.rb:3:in `block in <class:Photo>' 

답변

1

당신이 경우 블록에 값을 할당하는 것 같습니다 : 당신이 정규식에 대해 그것을 일치하려는 경우

true if file.attachment_content_type = /gif/ && file.size 

, 실제로이 같은 =~를 사용하려면 :

true if file.attachment_content_type =~ /gif/ && file.size 
+0

감사합니다. 그러나 문제는 여전히 불행히도 지속됩니다. –