File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ The valid types for fields are as follows:
77
77
- ``Regexp``
78
78
- ``Set``
79
79
- ``String``
80
- - ``Mongoid::StringifiedSymbol``, which may be specified simply as
80
+ - ``Mongoid::StringifiedSymbol``, which may be specified simply as
81
81
``StringifiedSymbol`` in the scope of a class which included
82
82
``Mongoid::Document``.
83
83
- ``Symbol``
@@ -1304,6 +1304,19 @@ a ``ReadonlyAttribute`` exception will be raised:
1304
1304
band.update_attribute(:name, "Tool") # Raises the error.
1305
1305
band.remove_attribute(:name) # Raises the error.
1306
1306
1307
+ Assignments to read-only attributes using their setters will be ignored:
1308
+
1309
+ .. code-block:: ruby
1310
+
1311
+ b = Band.create!(name: "The Rolling Stones")
1312
+ # => #<Band _id: 6287a3d5d1327a5292535383, name: "The Rolling Stones", origin: nil>
1313
+ b.name = "The Smashing Pumpkins"
1314
+ # => "The Smashing Pumpkins"
1315
+ b.name
1316
+ # => "The Rolling Stones"
1317
+
1318
+ Calls to atomic persistence operators, like ``bit`` and ``inc``, will persist
1319
+ changes to readonly fields.
1307
1320
1308
1321
Timestamp Fields
1309
1322
================
You can’t perform that action at this time.
0 commit comments