Sha256: dbd81fd53432b06774f6e30eded6c923796c241d325a83ee70ecc10adb11576f

Contents?: true

Size: 1.85 KB

Versions: 12

Compression:

Stored size: 1.85 KB

Contents

"!https://secure.travis-ci.org/locomotivecms/custom_fields.png!":http://travis-ci.org/locomotivecms/custom_fields

h1. CustomFields

Manage custom fields to a mongoid document or a collection. This module is one of the core features we implemented in our custom cms, 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 / 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.

h2. Requirements

ActiveSupport 3.2.13, MongoDB 2.0 and Mongoid 3.1.3

h2. Examples

h3. On a has_many relationship

bc.. class Company
  include CustomFields::Source

  has_many :employees

  custom_fields_for :employees
end

class Employee
  include CustomFields::Target

  field :name, String

  belongs_to :company, :inverse_of => :employees
end

company = Company.new
company.employees_custom_fields.build :label => 'His/her position', :name => 'position', :type => 'string', :required => true

company.save

company.employees.build :name => 'Michael Scott', :position => 'Regional manager'

another_company = Company.new
employee = another_company.employees.build
employee.position # returns a "not defined method" error

h3. On the class itself

[IN PROGRESS]

bc.. class Company
  custom_fields_for_itself
end

company = Company.new
company.self_metadata_custom_fields.build :label => 'Shipping Address', :name => 'address', :type => 'text'

company.save

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

another_company = Company.new
other_company.self_metadata.address # returns a "not defined method" error

h2. Contact

Feel free to contact me at didier at nocoffee dot fr.

Copyright (c) 2013 NoCoffee, released under the MIT license

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
custom_fields-2.3.2 README.textile
custom_fields-2.4.0.rc1 README.textile
gnuside-custom_fields-2.3.2.2 README.textile
gnuside-custom_fields-2.3.2 README.textile
gnuside-custom_fields-2.3.1.1 README.textile
gnuside-custom_fields-2.3.1 README.textile
custom_fields-2.3.1 README.textile
custom_fields-2.3.0 README.textile
custom_fields-2.2.3 README.textile
custom_fields-2.2.2 README.textile
custom_fields-2.2.1 README.textile
custom_fields-2.2.0 README.textile