Skip to content

Commit 71679dc

Browse files
committed
Update to match suggested changes
1 parent 51d2c2f commit 71679dc

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lib/jsonapi_errorable/validatable.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
module JsonapiErrorable
22
module Validatable
3-
# @param relationships: nil [Hash] list of relationships to be serialized as errors
3+
# @param relationships: nil [ Hash or FalseClass ] list of relationships whose errors should be serialized
4+
# Defaults to the deserialized data.relationships of Json:api Payload
45
# @param record [ ActiveModel ] Object that implements ActiveModel
56
def render_errors_for(record, relationships: nil)
6-
validation = Serializers::Validation.new(
7-
record,
8-
relationships || deserialized_params.relationships
9-
)
10-
7+
relationships =
8+
if relationships == false
9+
{}
10+
else
11+
relationships || deserialized_params.relationships
12+
end
13+
14+
validation = Serializers::Validation.new(record, relationships)
1115

1216
render \
1317
json: { errors: validation.errors },

0 commit comments

Comments
 (0)