module Ants
¶ ↑
IMPORTANT: this default value raises “stack level too deep” if concern is
included for existing objects, to fix issue update _position value for all objects like this: > ModelClass.all.set(_position: 1000)
¶ ↑
¶ ↑
IMPORTANT: this default value raises “stack level too deep” if concern is
included for existing objects, to fix issue update _position value for all objects like this: > ModelClass.all.set(_position: 1000)
¶ ↑
¶ ↑
Ants::Slug
provides a flexible way to define a custom slug on a top of Mongoid::Slug module, a few cases are covered:
1. if _slug is not defined, slug is autogenerated based on specified configuration 2. if _slug is defined it's used as default 3. if _slug is empty slug is autogenerated as in step 1 4. if slug configuration field has changed value and _slug is set, _slug is used as default
¶ ↑
class Book
include Mongoid::Document include Mongoid::SortedRelations field :title has_many :chapters sorted_relations_for :chapters has_and_belongs_to_many :authors sorted_relations_for :authors
end
b = Book.create(‘Hello’)
b.sorted_chapter_ids = [ Chapter.create(:title => ‘The End’).id,
Chapter.create(:title => 'Part 3' ).id, Chapter.create(:title => 'Part 2' ).id, Chapter.create(:title => 'Part 1' ).id, Chapter.create(:title => 'Intro' ).id ]
b.sorted_chapters()
book.sorted_author_ids = [ Author.create(:name => ‘Sun Tzu’).id,
Author.create(:name => 'Sun Wu' ).id, Author.create(:name => 'Lao Zi' ).id ]
book.sorted_authors()
¶ ↑
Constants
- VERSION