1

这是我的验证:

describe User
  it { should validate_attachment_size(:avatar).less_than(20.megabytes) }
end

这是我的用户模型:

class User < ActiveRecord::Base
  validates_attachment :avatar, :content_type => { :content_type => /image/ }, size: { in: 0..20.megabytes }, allow_blank: true
end

我不断收到的错误是:

Failure/Error: it { should validate_attachment_size(:avatar).less_than(20.megabytes) }
       Attachment avatar must be between  and 20971520 bytes

不知道为什么这会失败。任何帮助是极大的赞赏!

4

0 回答 0