-
Type: Bug
-
Resolution: Fixed
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: None
-
Fully Compatible
The message produced is as follows:
Mongoid::Errors::UnknownAttribute in LogosController#create
message:
Attempted to set a value for 'image' which is not allowed on the model Logo.
summary:
Without including Mongoid::Attributes::Dynamic in your model and the attribute does not already exist in the attributes hash, attempting to call Logo#image= for it is not allowed. This is also triggered by passing the attribute to any method that accepts an attributes hash, and is raised instead of getting a NoMethodError.
resolution:
You can include Mongoid::Attributes::Dynamic if you expect to be writing values for undefined fields often.
Suggested replacement:
Mongoid::Errors::UnknownAttribute in LogosController#create
message:
Attempted to set a value for 'image' which is not allowed on the model Logo.
summary:
Logo#image= was called to set a value for the 'image' attribute but there is no 'image' field defined and Mongoid::Attributes::Dynamic is not included in the model. This error is also triggered if the unknown attribute is passed to any method that accepts an attributes hash, such as Logo#attributes=, and is raised instead of NoMethodError.
resolution:
Explicitly define the field 'image' in Logo or include Mongoid::Attributes::Dynamic if you expect to be storing values in fields that are not explicitly defined often.