Module: RailsCom::AttachedOne
- Included in:
- ActiveStorage::Attached::One
- Defined in:
- lib/rails_com/active_storage/attached_macros.rb
Instance Method Summary collapse
Instance Method Details
#attached? ⇒ Boolean
14 15 16 |
# File 'lib/rails_com/active_storage/attached_macros.rb', line 14 def attached? &.id? end |
#attachment ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/rails_com/active_storage/attached_macros.rb', line 3 def if super return super elsif defined?(@attachment) return @attachment end id = ActiveStorage::BlobDefault.defaults["#{record.class.name}_#{name}"] @attachment = (blob: ActiveStorage::Blob.find(id)) if id end |