Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error where polymorphic relation not set #54

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/jsonapi/authorization/authorizing_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ def related_models
[:to_one, :to_many].flat_map do |rel_type|
data[rel_type].flat_map do |assoc_name, assoc_value|
case assoc_value
when nil
next
when Hash # polymorphic relationship
resource_class = @resource_klass.resource_for(assoc_value[:type].to_s)
resource_class.find_by_key(assoc_value[:id], context: context)._model
Expand All @@ -257,7 +259,7 @@ def related_models
primary_key = resource_class._primary_key
resource_class._model_class.where(primary_key => assoc_value)
end
end
end.compact
end
end

Expand Down