Skip to content

Commit b7adbb8

Browse files
committed
passing association owner to relationship_links_for
1 parent af304f1 commit b7adbb8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/active_model/serializer/adapter/json_api.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,13 @@ def relationship_value_for(serializer, options = {})
176176
end
177177
end
178178

179-
def relationship_links_for(name, serializer, options = {})
179+
def relationship_links_for(name, owner, options = {})
180180
if options[:links] == true
181-
{ related: url_helper.url_for([serializer.object, name]) }
181+
{ related: url_helper.url_for([owner, name]) }
182182
else
183183
options[:links].inject({}) do |hash, (key, link)|
184184
hash[key] = if link.is_a? Proc
185-
link.call(serializer.object, name)
185+
link.call(owner, name)
186186
else
187187
link
188188
end
@@ -201,7 +201,7 @@ def relationships_for(serializer)
201201
end
202202

203203
if association.options.fetch(:links, false)
204-
hash[association.key][:links] = relationship_links_for(association.name, serializer, association.options)
204+
hash[association.key][:links] = relationship_links_for(association.name, serializer.object, association.options)
205205
end
206206
end
207207
end

0 commit comments

Comments
 (0)