File tree Expand file tree Collapse file tree 3 files changed +14
-6
lines changed Expand file tree Collapse file tree 3 files changed +14
-6
lines changed Original file line number Diff line number Diff line change 373
373
resolution : " Set the values from the parent, or redefine the association
374
374
with only a single definition in the parent."
375
375
invalid_value :
376
- message : " Value of type %{value_class } cannot be written to a field of type %{field_class}"
377
- summary : " Tried to set a value of type %{value_class} to a field of type %{field_class}"
378
- resolution : " Verify if the value to be set correspond to field definition"
376
+ message : " The value %{value } cannot be written to a field of type %{field_class}"
377
+ summary : " The value %{value} could not be coerced to type %{field_class}"
378
+ resolution : " Verify that the value to be set corresponds to the field definition"
379
379
mixed_relations :
380
380
message : " Referencing a(n) %{embedded} document from the %{root}
381
381
document via a non-embedded association is not allowed since the
Original file line number Diff line number Diff line change @@ -7,9 +7,17 @@ module Errors
7
7
# For example when try to set an Array value to a Hash attribute.
8
8
#
9
9
class InvalidValue < MongoidError
10
- def initialize ( field_class , value_class )
10
+
11
+ # Create the new error.
12
+ #
13
+ # @param [ Class ] field_class The class of the field attempting to be
14
+ # assigned to.
15
+ # @param [ Object ] value The value being assigned.
16
+ #
17
+ # @api private
18
+ def initialize ( field_class , value )
11
19
super (
12
- compose_message ( "invalid_value" , { value_class : value_class , field_class : field_class } )
20
+ compose_message ( "invalid_value" , { value : value , field_class : field_class } )
13
21
)
14
22
end
15
23
end
Original file line number Diff line number Diff line change @@ -244,7 +244,7 @@ def _mongoid_wrap_mongoize(object)
244
244
return if object . nil?
245
245
yield . tap do |res |
246
246
if res . nil?
247
- raise Errors ::InvalidValue . new ( self , object . class )
247
+ raise Errors ::InvalidValue . new ( self , object )
248
248
end
249
249
end
250
250
end
You can’t perform that action at this time.
0 commit comments