No commit activity in last 3 years
No release in over 3 years
This is a port of classic Rails' acts_as_list to Mongo Mapper. This Mongo Mapper plugin provides the capabilities for sorting and reordering a number of objects in a list. If you do not specify custom position column in the options, a key named position will be added and used by default.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

 Project Readme

mongo_mapper_acts_as_list¶ ↑

This is a port of classic Rails’ acts_as_list to Mongo Mapper. This MongoMapper plugin provides the capabilities for sorting and reordering a number of objects in a list. If you do not specify custom position column in the options, a key named position will be added and used by default.

It has (almost) the same functionality and passes the original test-suite. Scope needs to be defined as symbol or array of symbols. It does not work for Embedded Documents.

Installation¶ ↑

Add this to your Gemfile and run the bundle command:

gem 'mongo_mapper_acts_as_list'

Example¶ ↑

class TodoList
  include MongoMapper::Document

  many :todo_items, :order => "position"
end

class TodoItem
  include MongoMapper::Document
  include MongoMapper::Plugins::ActsAsList

  key :todo_list_id, ObjectId
  belongs_to :todo_list

  acts_as_list :scope => :todo_list_id
end

todo_list.first.move_to_bottom
todo_list.last.move_higher

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.

Original Rails’ acts_as_list Copyright © 2007 David Heinemeier Hansson, released under the MIT license