class FixtureSet
Ruby on Rails 8.1.2
Since v7.0.10Active Storage FixtureSet
Fixtures are a way of organizing data that you want to test against; in short, sample data.
To learn more about fixtures, read the ActiveRecord::FixtureSet documentation.
YAML
Like other Active Record-backed models, ActiveStorage::Attachment and ActiveStorage::Blob records inherit from ActiveRecord::Base instances and therefore can be populated by fixtures.
Consider a hypothetical Article model class, its related fixture data, as well as fixture data for related ActiveStorage::Attachment and ActiveStorage::Blob records:
# app/models/article.rb class Article < ApplicationRecord has_one_attached :thumbnail end
# fixtures/active_storage/blobs.yml first_thumbnail_blob: <%= ActiveStorage::FixtureSet.blob filename: "first.png" %>
# fixtures/active_storage/attachments.yml first_thumbnail_attachment: name: thumbnail record: first (Article) blob: first_thumbnail_blob
When processed, Active Record will insert database records for each fixture entry and will ensure the Active Storage relationship is intact.
Inherits from
Includes
Methods (defined here)
Methods (inherited)
From ActiveSupport::Testing::FileFixtures (1)
From Object (17)
- # acts_like?
- # blank?
- # deep_dup
- # duplicable?
- # html_safe?
- # in?
- # instance_values
- # instance_variable_names
- # presence
- # presence_in
- # present?
- # to_param
- # to_query
- # try
- # try!
- # with
- # with_options
From ActiveSupport::Concern (3)
- # class_methods
- # included
- # prepended
From ActiveSupport::NumericWithFormat (2)
- # to_formatted_s
- # to_fs