You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+51-51
Original file line number
Diff line number
Diff line change
@@ -23,35 +23,35 @@ Note that closure_tree is being developed for Rails 3.1.x
23
23
24
24
Note that if the column is null, the tag will be considered a root node.
25
25
26
-
```ruby
27
-
classAddParentIdToTag < ActiveRecord::Migration
28
-
defchange
29
-
add_column :tag, :parent_id, :integer
30
-
end
26
+
```ruby
27
+
classAddParentIdToTag < ActiveRecord::Migration
28
+
defchange
29
+
add_column :tag, :parent_id, :integer
31
30
end
32
-
```
31
+
end
32
+
```
33
33
34
34
5. Add a database migration to store the hierarchy for your model. By
35
35
convention the table name will be the model's table name, followed by
36
36
"_hierarchy". Note that by calling ```acts_as_tree```, a "virtual model" (in this case, ```TagsHierarchy```) will be added automatically, so you don't need to create it.
37
37
38
-
```ruby
39
-
class CreateTagHierarchies < ActiveRecord::Migration
40
-
def change
41
-
create_table :tag_hierarchies, :id => false do |t|
42
-
t.integer :ancestor_id, :null => false # ID of the parent/grandparent/great-grandparent/... tag
43
-
t.integer :descendant_id, :null => false # ID of the target tag
44
-
t.integer :generations, :null => false # Number of generations between the ancestor and the descendant. Parent/child = 1, for example.
45
-
end
38
+
```ruby
39
+
class CreateTagHierarchies < ActiveRecord::Migration
40
+
def change
41
+
create_table :tag_hierarchies, :id => false do |t|
42
+
t.integer :ancestor_id, :null => false # ID of the parent/grandparent/great-grandparent/... tag
43
+
t.integer :descendant_id, :null => false # ID of the target tag
44
+
t.integer :generations, :null => false # Number of generations between the ancestor and the descendant. Parent/child = 1, for example.
0 commit comments