Skip to content

Commit fe08cc5

Browse files
committed
fix: relationship_name overrides name
1 parent 870bd62 commit fe08cc5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/anchor/resource.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ def anchor_relationships_properties(included_fields:)
161161
# @return [Anchor::Types::Reference, Anchor::Types::Array<Anchor::Types::Reference>, Anchor::Types::Maybe<Anchor::Types::Reference>]
162162
def relationship_type_for(rel, resource_klass, name)
163163
ref = Anchor::Types::Reference.new(resource_klass.anchor_schema_name)
164-
reflection = _model_class.try(:reflections).try(:[], name.to_s)
164+
model_relationship_name = (rel.options[:relation_name] || name).to_s
165+
reflection = _model_class.try(:reflections).try(:[], model_relationship_name)
165166
wrapper = if reflection
166167
Anchor::Types::Inference::ActiveRecord.wrapper_from_reflection(reflection)
167168
else

0 commit comments

Comments
 (0)