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