Validate Attachment Content Type Paperclip

后端 未结 4 866
生来不讨喜
生来不讨喜 2021-01-06 03:12

Is it possible to enforce a \'content type\' validation in paperclip without enforcing a \'presence\' validation (i.e. allow blanks)? I currently have:

class         


        
4条回答
  •  我在风中等你
    2021-01-06 03:41

    This worked for me;

    validates_attachment :image1, :presence => true,
                             :content_type => { :content_type => "image/jpg" },
                             :size => { :in => 0..10.kilobytes }
    

提交回复
热议问题