Skip to content
Manage custom fields to a mongoid document or a collection
Find file
Latest commit 5540ca2 Mar 8, 2016 @did did bump version to 2.7.0.rc1
Failed to load latest commit information.
lib bump version to 2.7.0.rc1 Mar 8, 2016
spec pick the translation of an option name in the right locale before loo… Feb 20, 2016
.gitignore [✔] Fixed `.gitignore`. Dec 27, 2014
.simplecov [➠] Updated `simplecov`. Dec 27, 2014
.travis.yml [Travis] Bundler that comes with Ruby 2.1 is too old Dec 25, 2015
Gemfile upgrade gems Jan 18, 2016
Gemfile.lock bump version to 2.7.0.rc1 Mar 8, 2016
LICENSE [➠] Updated README. Jan 3, 2015 bump version to 2.5.0 + update README Jan 12, 2016
Rakefile clean the gemspec + remove useless gems Dec 24, 2015
custom_fields.gemspec upgrade to mongoid 5.1.0 Feb 17, 2016


Travis CI Status Gemnasium Status

Manage custom fields to a Mongoid document or a collection. This module is one of the core features we implemented in our custom CMS, named LocomotiveCMS. Basically, its aim is to provide to editors a way to manage extra fields to a Mongoid document through, for instance, a web UI.

The main goals:

  • Offering a very secure way to add, edit and delete extra fields to a Mongoid document.
  • Scoping the modifications added to a Mongoid document, so that other documents of the same class won't be updated.


  • MongoDB 3.x
  • Mongoid 5.x
  • ActiveSupport 4.2.x


On a has_many relationship

class Company
  include CustomFields::Source

  has_many :employees

  custom_fields_for :employees

class Employee
  include CustomFields::Target

  field :name, String

  belongs_to :company, inverse_of: :employees

company = label: 'His/her position', name: 'position', type: 'string', required: true name: 'Michael Scott', position: 'Regional manager'

another_company =
employee =
employee.position # Returns a `not defined method` error

On the class itself


class Company

company = label: 'Shipping Address', name: 'address', type: 'text'

company.self_metadata.address = '700 S Laflin, 60607 Chicago'

another_company =
other_company.self_metadata.address # Returns a `not defined method` error


Run specs

Run rspec or rake.

Test Coverage

Run COVERAGE=true rspec or COVERAGE=true rake.


Feel free to contact me at did at locomotivecms dot com.


Copyright (c) 2013-2016 NoCoffee, released under the MIT License (MIT), see LICENSE.

Something went wrong with that request. Please try again.