0.01
No commit activity in last 3 years
No release in over 3 years
An easy way to make Mongoid documents order-able by adding position field
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 2.0.0.beta.20
 Project Readme

mongoid_order¶ ↑

An easy way to make mongoid documentation order-able.

This class is extracted from benedikt’s great gem github.com/benedikt/mongoid-tree with some modifications. Thanks to benedikt!

Requirements¶ ↑

  • mongoid (>= 2.0.0.beta.20)

Install¶ ↑

To install mongoid_order, simply add it to your Gemfile:

gem 'mongoid_order'

In order to get the latest development version of mongoid_order:

gem 'mongoid_order', :git => 'https://github.com/arkxu/mongoid_order.git'

And then:

bundle install

Usage¶ ↑

Add the include Mongoid::Orderable in the model:

class Node
  include Mongoid::Document
  include Mongoid::Orderable
end

Ordering¶ ↑

This will add a position field to your document and provide additional utility methods:

node.move_up
node.move_down
node.move_to_top
node.move_to_bottom
node.move_above(other)
node.move_below(other)

node.at_top?
node.at_bottom?

Known issues¶ ↑

See github.com/arkxu/mongoid_order/issues

Repository¶ ↑

See github.com/arkxu/mongoid_order and feel free to fork it!

Contributors¶ ↑

See a list of all contributors at github.com/arkxu/mongoid_order/contributors. Thanks a lot everyone!

Copyright © 2011 Ark Xu. See LICENSE for details.