class method
self.blob
Ruby on Rails 8.1.2
Since v7.0.10Signature
self.blob(filename:, **attributes)
Generate a YAML-encoded representation of an ActiveStorage::Blob instance’s attributes, resolve the file relative to the directory mentioned by ActiveSupport::Testing::FileFixtures.file_fixture, and upload the file to the Service
Examples
# tests/fixtures/active_storage/blobs.yml second_thumbnail_blob: <%= ActiveStorage::FixtureSet.blob( filename: "second.svg", ) %> third_thumbnail_blob: <%= ActiveStorage::FixtureSet.blob( filename: "third.svg", content_type: "image/svg+xml", service_name: "public" ) %>
Parameters
-
filenamekeyreq -
attributeskeyrest
Source
# File activestorage/lib/active_storage/fixture_set.rb, line 66
def self.blob(filename:, **attributes)
new.prepare Blob.new(filename: filename, key: generate_unique_secure_token), **attributes
end
Defined in activestorage/lib/active_storage/fixture_set.rb line 66
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveStorage::FixtureSet