Skip to content

Commit

Permalink
attach_fields polymorphism warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Bob committed Sep 6, 2024
1 parent 4d6b7ab commit 0bd0b1b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docs/3.0/associations/has_many.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@ field :patrons,
}
```

:::warning
If the through model uses **polymorphism**, the type must be included as a hidden field:

```ruby{6}
field :patrons,
as: :has_many,
through: :patronships,
attach_fields: -> {
field :review, as: :text
field :patronship_type, as: :hidden, default: "TheType"
}
```
:::

<Image src="/assets/img/3_0/has_many/attach-fields.gif" width="600" height="338" alt="" />
</Option>

Expand Down

0 comments on commit 0bd0b1b

Please sign in to comment.