Commit 9197ef9
committed
adds ActiveRecord 5.0.0.beta1 support for tree roots; fixes #195
AR 5 now defaults a `belongs_to` relation to be required. This does
not work in a tree where the root will not have a `belongs_to :parent` relationship.
To manage this change, AR 5 adds an `optional: true` key, which I have added here.
However, this key is not allowed in versions prior to AR 5 and will raise an exception,
so I've added a method that checks the version and strips the `optional` key if necessary.
This will maintain backwards compatibility with AR 4 without changing any
functionality.1 parent 6a67e3a commit 9197ef9
2 files changed
+11
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
79 | 83 | | |
80 | 84 | | |
81 | 85 | | |
| |||
0 commit comments