Alternative to validates_attachment_presence

Hi, in Paperclip I used to use validates_attachment_presence: image to prevent users from saving an instance without attaching an image.

Is there something like that in Shrine?

Thank you!

Hi, you can use ActiveRecord’s presence validator:

class Photo < ActiveRecord::Base
  include ImageUploader::Attachment(:image)
  validates_presence_of :image
end
1 Like