Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

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

tree: af7bf30f0b

Fetching latest commit…

Cannot retrieve the latest commit at this time

README.rdoc

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 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.

Something went wrong with that request. Please try again.