|
83 | 83 | </li> |
84 | 84 | <li> |
85 | 85 | <strong>Support for <a href="#concurrency">concurrency</a></strong> (using <a href="https://github.com/mceachen/with_advisory_lock">with_advisory_lock</a>)</li> |
86 | | -<li><strong>Support for Rails 3.2, 4.0, and 4.1</strong></li> |
87 | | -<li><strong>Support for Ruby 1.9, 2.1, and jRuby 1.6.13</strong></li> |
| 86 | +<li><strong>Support for ActiveRecord 4.1, 4.2 and 5.0.alpha</strong></li> |
| 87 | +<li><strong>Support for Ruby 2.2 and JRuby 9000</strong></li> |
88 | 88 | <li>Support for reparenting children (and all their descendants)</li> |
89 | 89 | <li>Support for <a href="#sti">single-table inheritance (STI)</a> within the hierarchy</li> |
90 | 90 | <li> |
|
121 | 121 | <h2> |
122 | 122 | <a id="installation" class="anchor" href="#installation" aria-hidden="true"><span class="octicon octicon-link"></span></a>Installation</h2> |
123 | 123 |
|
124 | | -<p>Note that closure_tree only supports Rails 3.2 and later, and has test coverage for MySQL, PostgreSQL, and SQLite.</p> |
| 124 | +<p>Note that closure_tree only supports ActiveRecord 4.1 and later, and has test coverage for MySQL, PostgreSQL, and SQLite.</p> |
125 | 125 |
|
126 | 126 | <ol> |
127 | 127 | <li><p>Add <code>gem 'closure_tree'</code> to your Gemfile </p></li> |
|
147 | 147 | </li> |
148 | 148 | <li> |
149 | 149 | <p>Add a migration to add a <code>parent_id</code> column to the hierarchical model. |
150 | | -You may want to also <a href="#sort_order">add a column for deterministic ordering of children</a>, but that's optional.</p> |
| 150 | +You may want to also <a href="#deterministic-ordering">add a column for deterministic ordering of children</a>, but that's optional.</p> |
151 | 151 |
|
152 | 152 | <div class="highlight highlight-ruby"><pre><span class="pl-k">class</span> <span class="pl-en">AddParentIdToTag<span class="pl-e"> < ActiveRecord::Migration</span></span> |
153 | 153 | <span class="pl-k">def</span> <span class="pl-en">change</span> |
@@ -458,23 +458,6 @@ <h2> |
458 | 458 | <span class="pl-k">class</span> <span class="pl-en">WhereTag<span class="pl-e"> < Tag</span></span> ; <span class="pl-k">end</span> |
459 | 459 | <span class="pl-k">class</span> <span class="pl-en">WhatTag<span class="pl-e"> < Tag</span></span> ; <span class="pl-k">end</span></pre></div> |
460 | 460 |
|
461 | | -<p>Please note that Rails (<= 3.2) doesn't handle polymorphic associations correctly if |
462 | | -you use the <code>:type</code> attribute, so <strong>this doesn't work</strong>:</p> |
463 | | - |
464 | | -<div class="highlight highlight-ruby"><pre><span class="pl-c"># BAD: ActiveRecord ignores the :type attribute:</span> |
465 | | -root.children.create(<span class="pl-c1">name:</span> <span class="pl-s"><span class="pl-pds">"</span>child<span class="pl-pds">"</span></span>, <span class="pl-c1">type:</span> <span class="pl-s"><span class="pl-pds">"</span>WhenTag<span class="pl-pds">"</span></span>)</pre></div> |
466 | | - |
467 | | -<p>Instead, use either <code>.add_child</code> or <code>children <<</code>:</p> |
468 | | - |
469 | | -<div class="highlight highlight-ruby"><pre><span class="pl-c"># GOOD!</span> |
470 | | -a <span class="pl-k">=</span> <span class="pl-c1">Tag</span>.create!(<span class="pl-c1">name:</span> <span class="pl-s"><span class="pl-pds">"</span>a<span class="pl-pds">"</span></span>) |
471 | | -b <span class="pl-k">=</span> <span class="pl-c1">WhenTag</span>.<span class="pl-k">new</span>(<span class="pl-c1">name:</span> <span class="pl-s"><span class="pl-pds">"</span>b<span class="pl-pds">"</span></span>) |
472 | | -a.children <span class="pl-k"><<</span> b |
473 | | -c <span class="pl-k">=</span> <span class="pl-c1">WhatTag</span>.<span class="pl-k">new</span>(<span class="pl-c1">name:</span> <span class="pl-s"><span class="pl-pds">"</span>c<span class="pl-pds">"</span></span>) |
474 | | -b.add_child(c)</pre></div> |
475 | | - |
476 | | -<p>See <a href="https://github.com/mceachen/closure_tree/issues/43">issue 43</a> for more information.</p> |
477 | | - |
478 | 461 | <h2> |
479 | 462 | <a id="deterministic-ordering" class="anchor" href="#deterministic-ordering" aria-hidden="true"><span class="octicon octicon-link"></span></a>Deterministic ordering</h2> |
480 | 463 |
|
@@ -694,10 +677,9 @@ <h2> |
694 | 677 | <p>Closure tree is <a href="http://travis-ci.org/#!/mceachen/closure_tree">tested under every valid combination</a> of</p> |
695 | 678 |
|
696 | 679 | <ul> |
697 | | -<li>Ruby 1.9.3, 2.1.2 (and sometimes head)</li> |
698 | | -<li>Rubinius 2.2.1+ (and sometimes head)</li> |
699 | | -<li>jRuby 1.9mode (and sometimes head)</li> |
700 | | -<li>The latest Rails 3.2, 4.0, 4.1, 4.2 and master branches</li> |
| 680 | +<li>Ruby 2.2 (and sometimes head)</li> |
| 681 | +<li>jRuby 9000 (and sometimes head)</li> |
| 682 | +<li>The latest ActiveRecord 4.1, 4.2, and master branch</li> |
701 | 683 | <li>Concurrency tests for MySQL and PostgreSQL. SQLite is tested in a single-threaded environment.</li> |
702 | 684 | </ul> |
703 | 685 |
|
|
0 commit comments