class method self.attachment

Ruby on Rails 8.1.2

Since v6.1.7.10

Available in: v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

self.attachment(fixture_set_name, label, column_type: :integer)

Fixtures support Action Text attachments as part of their body HTML.

Examples

For example, consider a second Article fixture declared in test/fixtures/articles.yml:

second:
  title: Another Article

You can attach a mention of articles(:first) to second‘s content by embedding a call to ActionText::FixtureSet.attachment in the body: value in test/fixtures/action_text/rich_texts.yml:

second:
  record: second (Article)
  name: content
  body: <div>Hello, <%= ActionText::FixtureSet.attachment("articles", :first) %></div>

Parameters

fixture_set_name req
label req
column_type key = :integer
Source
# File actiontext/lib/action_text/fixture_set.rb, line 61
    def self.attachment(fixture_set_name, label, column_type: :integer)
      signed_global_id = ActiveRecord::FixtureSet.signed_global_id fixture_set_name, label,
        column_type: column_type, for: ActionText::Attachable::LOCATOR_NAME

      %(<#{Attachment.tag_name} sgid="#{signed_global_id}"></#{Attachment.tag_name}>)
    end

Defined in actiontext/lib/action_text/fixture_set.rb line 61 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionText::FixtureSet

Type at least 2 characters to search.

↑↓ navigate · open · esc close