mongoid/mongoid-site — Issue #115: Fix Mass Assignment Documentation.
Author: durran
Created: 2012-02-10 08:21:01+00:00
State: open

According to http://mongoid.org/docs/documents/access.html "Attempt to set attributes a person, raising an error."
I am inferring that when mass assignment happens on a protected attributes happens, an error should be raised. Maybe I'm reading this wrong or the documentation is out dated. What I am seeing is that the protected attribute assignment silently fails.

This is what I see:

class Foo
include Mongoid::Document

field :open
field :secret

attr_protected :secret
end

Foo.new(open: 'blerg', secret: 'foo')
=> #

By the documentation attr_accessible is supposed to silently fail, and attr_protected should raise an error. I would prefer attr_protected mass assignment to raise and error.

Edit: I forgot to mention I am using Mongoid 2.4.3