Module: Ants
- Defined in:
- lib/concerns/ants/slug.rb,
lib/ants.rb,
lib/ants/engine.rb,
lib/ants/version.rb,
lib/concerns/ants/id.rb,
lib/concerns/ants/meta.rb,
lib/concerns/ants/hideable.rb,
lib/concerns/ants/versions.rb,
lib/concerns/ants/orderable.rb,
lib/concerns/ants/featurable.rb,
lib/concerns/ants/publication.rb,
lib/concerns/ants/sorted_relations.rb
Overview
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()
Defined Under Namespace
Modules: Featurable, Hideable, Id, Meta, Orderable, Publication, Slug, SortedRelations, Versions Classes: Engine
Constant Summary collapse
- VERSION =
"0.2.3"