Skip to content

Commit 9aa7193

Browse files
docs: limitations around STI and abstract classes
1 parent 9d08e12 commit 9aa7193

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,15 @@ item.update list: other_list, position: {after: 11}
267267

268268
It's important to note that in the examples above, `other_item` must already belong to the `other_list` scope.
269269

270+
##### Single Table Inheritance and Abstract Models
271+
Positioning requires a concrete table to work with and considers all records within that table as being in some scope. Therefore, it currently isn't possible to use `positioned` on abstract subclasses or when using STI. All calls to `position` must be on the base class.
272+
273+
If you must position child models separately, scope their position by the `type` column.
274+
275+
```rb
276+
positioned on: [:type]
277+
```
278+
270279
## Concurrency
271280

272281
The queries that this gem runs (especially those that seek the next position integer available) are vulnerable to race conditions. To this end, we lock the scope records to ensure that our model callbacks that determine and assign positions run sequentially. Previously we used an Advisory Lock for this purpose but this was difficult to test and a bit overkill in most situations. Where a scope doesn't exist, we lock all the records in the table.

0 commit comments

Comments
 (0)