We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 05a45c1 + 3814168 commit bc34f35Copy full SHA for bc34f35
activemodel/lib/active_model/attribute.rb
@@ -175,6 +175,19 @@ def type_cast(value)
175
type.deserialize(value)
176
end
177
178
+ def forgetting_assignment
179
+ # If this attribute was not persisted (with a `value_for_database`
180
+ # that might differ from `value_before_type_cast`) and `value` has not
181
+ # changed in place, we can simply dup this attribute to avoid
182
+ # deserialize / cast / serialize calls from computing the new
183
+ # attribute's `value_before_type_cast`.
184
+ if !defined?(@value_for_database) && !changed_in_place?
185
+ dup
186
+ else
187
+ super
188
+ end
189
190
+
191
private
192
def _original_value_for_database
193
value_before_type_cast
0 commit comments