Module: RailsExt::AttachedOne
- Defined in:
- lib/rails_com/rails_ext/attached_macros.rb
Instance Method Summary collapse
Instance Method Details
#attached? ⇒ Boolean
14 15 16 |
# File 'lib/rails_com/rails_ext/attached_macros.rb', line 14 def attached? &.id? end |
#attachment ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/rails_com/rails_ext/attached_macros.rb', line 4 def if super super elsif @blob_default ||= ActiveStorage::BlobDefault.find_by(record_class: record.class.name, name: name) @attachment ||= (blob: @blob_default.file_blob) end end |