Forbid dynamic fields like in Mongoid #476

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
1 participant

Nucc commented Nov 13, 2012

Use self.forbid_dynamic_fields in the model to forbid dynamic fields in a Document or use self.allow_dynamic_fields = false like in Mongoid.

class User
include MongoMapper::Document
self.allow_dynamic_fields = false

self.forbid_dynamic_fields

end

User.new.age = 21 # => NoMethodError
User.new(:age => 21) # => NoMethodError

@Nucc Nucc Added option to disable the dynamic fields in documents
Use self.forbid_dynamic_fields in the model to forbid dynamic fields or use self.allow_dynamic_fields = false like in Mongoid.
13abf29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment