Skip to content
Permalink
Browse files

more formatting

  • Loading branch information...
dhoss committed Oct 9, 2014
1 parent a250b5b commit cb92e42cf7b884d79243b419003c3ae347777ab5
Showing with 8 additions and 8 deletions.
  1. +8 −8 README.md
@@ -10,37 +10,37 @@ Synopsis
========

1. Create your migration
```
```
create_table :nodes do |t|
t.text :name
t.integer :parent_id
t.references :parent
end
add_index :nodes, [:parent_id, :id], :unique => true
```
```

2. Create your model
```
```
class Node < ActiveRecord::Base
include Treeify
config({:cols => [:name]})
validates_uniqueness_of :name
validates_uniqueness_of :parent_id, :scope=> :id
end
```
```
3. Create a tree of stuff
```
```
parent = Node.create(name: "parent node")
child = parent.children.create(name: "child 1")
child2 = child.children.create(name: "child 2")
```
```
4. Retrieve tree of stuff
```
```
parent.descendent_tree
```
```

License
=======

0 comments on commit cb92e42

Please sign in to comment.
You can’t perform that action at this time.