From 42259ce904eb2538761b32a793cbe390fb8272b7 Mon Sep 17 00:00:00 2001 From: fatkodima Date: Sun, 11 Feb 2018 17:53:23 +0200 Subject: has_(one/many)_attached presence validation --- activestorage/lib/active_storage/attached/one.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'activestorage/lib/active_storage/attached') diff --git a/activestorage/lib/active_storage/attached/one.rb b/activestorage/lib/active_storage/attached/one.rb index 0244232b2c..98477547c3 100644 --- a/activestorage/lib/active_storage/attached/one.rb +++ b/activestorage/lib/active_storage/attached/one.rb @@ -13,6 +13,10 @@ module ActiveStorage record.public_send("#{name}_attachment") end + def blank? + attachment.blank? + end + # Associates a given attachment with the current record, saving it to the database. # # person.avatar.attach(params[:avatar]) # ActionDispatch::Http::UploadedFile object -- cgit v1.2.3