An open API service indexing awesome lists of open source software.

https://github.com/shuber/nestable

Allows you to nest ActiveRecord records with various strategies like tree, set, path, etc.
https://github.com/shuber/nestable

Last synced: 17 days ago
JSON representation

Allows you to nest ActiveRecord records with various strategies like tree, set, path, etc.

Awesome Lists containing this project

README

          

= nestable

Allows you to nest ActiveRecord records with various strategies like tree, set, path, etc.

What makes it different than other nesting gems/plugins?

It aims to provide a standard interface to all nesting related methods no matter what strategy you decide to use.
Some strategies are better for read-heavy applications and others are better for write-heavy ones - but you always want
the same information - ancestors, children, descendants, siblings, etc. Your application code shouldn't have to change
just because you realized that you're better off storing records as a set instead of a tree.

== Requirements

ActiveRecord >= 3.0.0

== Installation

gem install nestable

== Usage

Simply call nestable in your model and pass the :strategy that you want to use along with any options related to it (see Strategies below).

class Comment < ActiveRecord::Base
nestable :strategy => :path, :scope => :post_id
end

== Strategies

Take a look at the documentation at http://rdoc.info/github/shuber/nestable/master/frames for more information about each strategy.

* :tree (Nestable::Strategy::Tree) default
* :path (Nestable::Strategy::Path)

== Note on Patches/Pull Requests

* Fork the project.
* Make your feature addition or bug fix.
* Add tests for it. This is important so I don't break it in a future version unintentionally.
* Commit, do not mess with Rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
* Send me a pull request. Bonus points for topic branches.