2

我遵循官方 github 存储库示例,但是当我在版本方法上定义条件时,我总是得到:

ArgumentError - wrong number of arguments (1 for 0):
(gem) carrierwave-0.8.0/lib/carrierwave/uploader/versions.rb:198:in `block in active_versions'
(gem) carrierwave-0.8.0/lib/carrierwave/uploader/versions.rb:192:in `active_versions'

这是我的代码:

class PhotoUploader < CarrierWave::Uploader::Base

    include CarrierWave::MiniMagick
    storage :file

    version :thumb_75, :if => :is_user? do
        process :resize_to_fill => [75, 75]
    end

    version :thumb_87, :if => :is_question? do
        process :resize_to_fill => [87, 87]
    end

    protected
    def is_user?
        model.class.to_s == 'Photo'
    end

    protected
    def is_question?
        model.class.to_s == 'Question'
    end

end

如果我删除它的工作条件......知道它可能是什么吗?谢谢

4

1 回答 1

6

你必须 makeis_user?is_question?方法来接受一个参数:

protected
def is_user?(picture)
    model.class.to_s == 'Photo'
end

protected
def is_question?(picture)
    model.class.to_s == 'Question'
end
于 2013-06-24T15:11:01.773 回答