aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/lib
diff options
context:
space:
mode:
authorfatkodima <fatkodima123@gmail.com>2018-02-11 17:53:23 +0200
committerfatkodima <fatkodima123@gmail.com>2018-02-11 17:53:23 +0200
commit42259ce904eb2538761b32a793cbe390fb8272b7 (patch)
tree67888a5c970b20aaecf88765d8255299dbc15e95 /activestorage/lib
parenta2a752d1026346e3a348682551dfc952f7cf3a58 (diff)
downloadrails-42259ce904eb2538761b32a793cbe390fb8272b7.tar.gz
rails-42259ce904eb2538761b32a793cbe390fb8272b7.tar.bz2
rails-42259ce904eb2538761b32a793cbe390fb8272b7.zip
has_(one/many)_attached presence validation
Diffstat (limited to 'activestorage/lib')
-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 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