aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/lib/active_storage/attached
diff options
context:
space:
mode:
authorEileen M. Uchitelle <eileencodes@users.noreply.github.com>2018-04-27 14:35:21 -0400
committerGitHub <noreply@github.com>2018-04-27 14:35:21 -0400
commitad0220a71a2d42191a3acf6118321b504f1ad70c (patch)
treee93585a7a5c5569ac1a3470986a592bd07cbc1a7 /activestorage/lib/active_storage/attached
parent1230253153edcccc1316f1ab9bc16684ba02b0ae (diff)
parent42259ce904eb2538761b32a793cbe390fb8272b7 (diff)
downloadrails-ad0220a71a2d42191a3acf6118321b504f1ad70c.tar.gz
rails-ad0220a71a2d42191a3acf6118321b504f1ad70c.tar.bz2
rails-ad0220a71a2d42191a3acf6118321b504f1ad70c.zip
Merge pull request #31956 from fatkodima/has_attached-presence-validation
has_(one/many)_attached presence validation
Diffstat (limited to 'activestorage/lib/active_storage/attached')
-rw-r--r--activestorage/lib/active_storage/attached/one.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activestorage/lib/active_storage/attached/one.rb b/activestorage/lib/active_storage/attached/one.rb
index a582ed0137..f992cb5f84 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