# MongoidFindBy [![Build Status](https://secure.travis-ci.org/Langwhich/mongoid_find_by.png)](https://secure.travis-ci.org/Langwhich/mongoid_find_by) MongoidFindBy adds simple functions to mongoid documents to find documents by dynamic fields. ## Install ```ruby gem 'mongoid_find_by' ``` ## Usage ```ruby class Person include Mongoid::Document include Mongoid::FindBy field :name, :type => String end ``` ```ruby # returns a single document Person.find_by_name('Thomas') Person.find_first_by_name('Thomas') Person.find_last_by_name('Thomas') # returns a document collection Person.find_all_by_name('Thomas') # throws Mongoid::Errors::DocumentNotFound # exception for non existent documents Person.find_by_name!('Thomas) ``` ## Credits Copyright (c) 2012 Langwhich GmbH