Skip to content

Commit 93f8ac4

Browse files
authored
Merge pull request #287 from gr8bit/patch-1
Update README with STI rebuild! behavior
2 parents 9baa885 + f023cb1 commit 93f8ac4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,18 @@ class WhereTag < Tag ; end
389389
class WhatTag < Tag ; end
390390
```
391391
392+
Note that if you call `rebuild!` on any of the subclasses, the complete Tag hierarchy will be emptied, thus taking the hiearchies of all other subclasses with it (issue #275). However, only the hierarchies for the class `rebuild!` was called on will be rebuilt, leaving the other subclasses without hierarchy entries.
393+
394+
You can work around that by overloading the `rebuild!` class method in all your STI subclasses and call the super classes `rebuild!` method:
395+
```ruby
396+
class WhatTag < Tag
397+
def self.rebuild!
398+
Tag.rebuild!
399+
end
400+
end
401+
```
402+
This way, the complete hierarchy including all subclasses will be rebuilt.
403+
392404
## Deterministic ordering
393405
394406
By default, children will be ordered by your database engine, which may not be what you want.

0 commit comments

Comments
 (0)