Sha256: bd5cb7eb5820bf07992d0e2ff82225dc348d4574da3f771e16963ab82b060825

Contents?: true

Size: 1.31 KB

Versions: 6

Compression:

Stored size: 1.31 KB

Contents

ants
======
[![GitHub version](https://badge.fury.io/gh/slate-studio%2Fants.svg)](http://badge.fury.io/gh/slate-studio%2Fants)
[![Build Status](https://travis-ci.org/slate-studio/ants.svg)](https://travis-ci.org/slate-studio/ants)
[![Code Climate](https://codeclimate.com/github/slate-studio/ants/badges/gpa.svg)](https://codeclimate.com/github/slate-studio/ants)
[![Coverage Status](https://coveralls.io/repos/slate-studio/ants/badge.svg)](https://coveralls.io/r/slate-studio/ants)

Collection of concerns and helpers for Rails + Mongoid + Character web development


### Sorted Relations

In Mongoid, the HM & HABTM relations return docs in random order. This workaround provides an ability to retrieve related documents in the same order it was stored.

Usage example:

  ```ruby
  class Post
    include Mongoid::Document
    include Ants::SortedRelations

    field :title

    has_and_belongs_to_many :authors
    sorted_relations_for :authors
  end

  post = Post.new title: 'RESTful actions with Mongosteen'
  post.sorted_author_ids = [ Author.create(name: "Oleksandr Kravets").id,
                             Author.create(name: "Roman Brazhnyk"   ).id,
                             Author.create(name: "Maxim Melnyk"     ).id ]

  post.sorted_authors.map(&:name)
  #=> ['Alexander Kravets', 'Roman Brazhnyk', 'Maxim Melnyk']
  ```

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ants-0.2.3 README.md
ants-0.2.2 README.md
ants-0.2.1 README.md
ants-0.2.0 README.md
ants-0.1.4 README.md
ants-0.1.1 README.md