Skip to content

Commit dd08a32

Browse files
committed
Fix code example for relationship specific method definitions
There is no such method or variable as `relationship` defined in the special record_for_#{relationship} method. For the commented-out code to actually work, we first need to fetch the relationship object before we can ask for the relation name.
1 parent 3b1d574 commit dd08a32

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,11 +735,13 @@ class PostResource < JSONAPI::Resource
735735
has_many :comments
736736

737737
# def record_for_author
738+
# relationship = self.class._relationship(:author)
738739
# relation_name = relationship.relation_name(context: @context)
739740
# records_for(relation_name)
740741
# end
741742

742743
# def records_for_comments
744+
# relationship = self.class._relationship(:comments)
743745
# relation_name = relationship.relation_name(context: @context)
744746
# records_for(relation_name)
745747
# end

0 commit comments

Comments
 (0)