Giter Club home page Giter Club logo

mongoid_order's Introduction

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.

mongoid_order's People

Watchers

James Cloos avatar Qiang Liu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.