{"action":"created","comment":{"url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/comments/36823082","id":36823082,"diff_hunk":"@@ -41,10 +43,17 @@ def fragment_cache(cached_hash, non_cached_hash)\n \n         private\n \n-        def add_relationships(resource, name, serializers)\n+        def add_relationships(resource, name, serializers, opts)\n           resource[:relationships] ||= {}\n-          resource[:relationships][name] ||= { data: [] }\n-          resource[:relationships][name][:data] += serializers.map { |serializer| { type: serializer.type, id: serializer.id.to_s } }\n+\n+          if opts.fetch(:data, true)\n+            resource[:relationships][name] ||= { data: [] }\n+            resource[:relationships][name][:data] += serializers.map { |serializer| { type: serializer.type, id: serializer.id.to_s } }\n+          end\n+          if opts.fetch(:links, false)\n+            resource[:relationships][name] ||= {}\n+            resource[:relationships][name][:links] = { related: url_helper.url_for([serializer.object, name]) }","path":"lib/active_model/serializer/adapter/json_api.rb","position":34,"original_position":34,"commit_id":"5d5715a285182e6661021285407116839a9f2d4b","original_commit_id":"5d5715a285182e6661021285407116839a9f2d4b","user":{"login":"bf4","id":142914,"avatar_url":"https://avatars.githubusercontent.com/u/142914?v=3","gravatar_id":"","url":"https://api.github.com/users/bf4","html_url":"https://github.com/bf4","followers_url":"https://api.github.com/users/bf4/followers","following_url":"https://api.github.com/users/bf4/following{/other_user}","gists_url":"https://api.github.com/users/bf4/gists{/gist_id}","starred_url":"https://api.github.com/users/bf4/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bf4/subscriptions","organizations_url":"https://api.github.com/users/bf4/orgs","repos_url":"https://api.github.com/users/bf4/repos","events_url":"https://api.github.com/users/bf4/events{/privacy}","received_events_url":"https://api.github.com/users/bf4/received_events","type":"User","site_admin":false},"body":"Did you consider using `Rails.application.routes.url_helpers` here instead of a reference to the controller?","created_at":"2015-08-12T02:59:16Z","updated_at":"2015-08-12T02:59:16Z","html_url":"https://github.com/rails-api/active_model_serializers/pull/1028#discussion_r36823082","pull_request_url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1028","_links":{"self":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/comments/36823082"},"html":{"href":"https://github.com/rails-api/active_model_serializers/pull/1028#discussion_r36823082"},"pull_request":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1028"}}},"pull_request":{"url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1028","id":41314681,"html_url":"https://github.com/rails-api/active_model_serializers/pull/1028","diff_url":"https://github.com/rails-api/active_model_serializers/pull/1028.diff","patch_url":"https://github.com/rails-api/active_model_serializers/pull/1028.patch","issue_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1028","number":1028,"state":"open","locked":false,"title":"Add supports for :links and :data options to has_many associations for jsonapi adapter","user":{"login":"lsylvester","id":191128,"avatar_url":"https://avatars.githubusercontent.com/u/191128?v=3","gravatar_id":"","url":"https://api.github.com/users/lsylvester","html_url":"https://github.com/lsylvester","followers_url":"https://api.github.com/users/lsylvester/followers","following_url":"https://api.github.com/users/lsylvester/following{/other_user}","gists_url":"https://api.github.com/users/lsylvester/gists{/gist_id}","starred_url":"https://api.github.com/users/lsylvester/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsylvester/subscriptions","organizations_url":"https://api.github.com/users/lsylvester/orgs","repos_url":"https://api.github.com/users/lsylvester/repos","events_url":"https://api.github.com/users/lsylvester/events{/privacy}","received_events_url":"https://api.github.com/users/lsylvester/received_events","type":"User","site_admin":false},"body":"Adds option to `has_many` relationships have links (`links: true`) and turn of data (`data: false`) for jsonapi.\r\n\r\nReplaces #840 \r\nFixes #834\r\n","created_at":"2015-07-31T07:43:09Z","updated_at":"2015-08-12T02:59:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4e9d97c2ba2bf91a0363ab9538fb94522bf1bb29","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1028/commits","review_comments_url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1028/comments","review_comment_url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1028/comments","statuses_url":"https://api.github.com/repos/rails-api/active_model_serializers/statuses/5d5715a285182e6661021285407116839a9f2d4b","head":{"label":"lsylvester:jsonapi-link-v-data","ref":"jsonapi-link-v-data","sha":"5d5715a285182e6661021285407116839a9f2d4b","user":{"login":"lsylvester","id":191128,"avatar_url":"https://avatars.githubusercontent.com/u/191128?v=3","gravatar_id":"","url":"https://api.github.com/users/lsylvester","html_url":"https://github.com/lsylvester","followers_url":"https://api.github.com/users/lsylvester/followers","following_url":"https://api.github.com/users/lsylvester/following{/other_user}","gists_url":"https://api.github.com/users/lsylvester/gists{/gist_id}","starred_url":"https://api.github.com/users/lsylvester/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsylvester/subscriptions","organizations_url":"https://api.github.com/users/lsylvester/orgs","repos_url":"https://api.github.com/users/lsylvester/repos","events_url":"https://api.github.com/users/lsylvester/events{/privacy}","received_events_url":"https://api.github.com/users/lsylvester/received_events","type":"User","site_admin":false},"repo":{"id":30995424,"name":"active_model_serializers","full_name":"lsylvester/active_model_serializers","owner":{"login":"lsylvester","id":191128,"avatar_url":"https://avatars.githubusercontent.com/u/191128?v=3","gravatar_id":"","url":"https://api.github.com/users/lsylvester","html_url":"https://github.com/lsylvester","followers_url":"https://api.github.com/users/lsylvester/followers","following_url":"https://api.github.com/users/lsylvester/following{/other_user}","gists_url":"https://api.github.com/users/lsylvester/gists{/gist_id}","starred_url":"https://api.github.com/users/lsylvester/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsylvester/subscriptions","organizations_url":"https://api.github.com/users/lsylvester/orgs","repos_url":"https://api.github.com/users/lsylvester/repos","events_url":"https://api.github.com/users/lsylvester/events{/privacy}","received_events_url":"https://api.github.com/users/lsylvester/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lsylvester/active_model_serializers","description":"ActiveModel::Serializer implementation and Rails hooks","fork":true,"url":"https://api.github.com/repos/lsylvester/active_model_serializers","forks_url":"https://api.github.com/repos/lsylvester/active_model_serializers/forks","keys_url":"https://api.github.com/repos/lsylvester/active_model_serializers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lsylvester/active_model_serializers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lsylvester/active_model_serializers/teams","hooks_url":"https://api.github.com/repos/lsylvester/active_model_serializers/hooks","issue_events_url":"https://api.github.com/repos/lsylvester/active_model_serializers/issues/events{/number}","events_url":"https://api.github.com/repos/lsylvester/active_model_serializers/events","assignees_url":"https://api.github.com/repos/lsylvester/active_model_serializers/assignees{/user}","branches_url":"https://api.github.com/repos/lsylvester/active_model_serializers/branches{/branch}","tags_url":"https://api.github.com/repos/lsylvester/active_model_serializers/tags","blobs_url":"https://api.github.com/repos/lsylvester/active_model_serializers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lsylvester/active_model_serializers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lsylvester/active_model_serializers/git/refs{/sha}","trees_url":"https://api.github.com/repos/lsylvester/active_model_serializers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lsylvester/active_model_serializers/statuses/{sha}","languages_url":"https://api.github.com/repos/lsylvester/active_model_serializers/languages","stargazers_url":"https://api.github.com/repos/lsylvester/active_model_serializers/stargazers","contributors_url":"https://api.github.com/repos/lsylvester/active_model_serializers/contributors","subscribers_url":"https://api.github.com/repos/lsylvester/active_model_serializers/subscribers","subscription_url":"https://api.github.com/repos/lsylvester/active_model_serializers/subscription","commits_url":"https://api.github.com/repos/lsylvester/active_model_serializers/commits{/sha}","git_commits_url":"https://api.github.com/repos/lsylvester/active_model_serializers/git/commits{/sha}","comments_url":"https://api.github.com/repos/lsylvester/active_model_serializers/comments{/number}","issue_comment_url":"https://api.github.com/repos/lsylvester/active_model_serializers/issues/comments{/number}","contents_url":"https://api.github.com/repos/lsylvester/active_model_serializers/contents/{+path}","compare_url":"https://api.github.com/repos/lsylvester/active_model_serializers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lsylvester/active_model_serializers/merges","archive_url":"https://api.github.com/repos/lsylvester/active_model_serializers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lsylvester/active_model_serializers/downloads","issues_url":"https://api.github.com/repos/lsylvester/active_model_serializers/issues{/number}","pulls_url":"https://api.github.com/repos/lsylvester/active_model_serializers/pulls{/number}","milestones_url":"https://api.github.com/repos/lsylvester/active_model_serializers/milestones{/number}","notifications_url":"https://api.github.com/repos/lsylvester/active_model_serializers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lsylvester/active_model_serializers/labels{/name}","releases_url":"https://api.github.com/repos/lsylvester/active_model_serializers/releases{/id}","created_at":"2015-02-19T00:52:50Z","updated_at":"2015-02-19T00:52:51Z","pushed_at":"2015-08-10T00:18:45Z","git_url":"git://github.com/lsylvester/active_model_serializers.git","ssh_url":"git@github.com:lsylvester/active_model_serializers.git","clone_url":"https://github.com/lsylvester/active_model_serializers.git","svn_url":"https://github.com/lsylvester/active_model_serializers","homepage":"","size":1550,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rails-api:master","ref":"master","sha":"03ddeeeec1e4eedafeb68eeccd59e8c3826b859d","user":{"login":"rails-api","id":2820360,"avatar_url":"https://avatars.githubusercontent.com/u/2820360?v=3","gravatar_id":"","url":"https://api.github.com/users/rails-api","html_url":"https://github.com/rails-api","followers_url":"https://api.github.com/users/rails-api/followers","following_url":"https://api.github.com/users/rails-api/following{/other_user}","gists_url":"https://api.github.com/users/rails-api/gists{/gist_id}","starred_url":"https://api.github.com/users/rails-api/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails-api/subscriptions","organizations_url":"https://api.github.com/users/rails-api/orgs","repos_url":"https://api.github.com/users/rails-api/repos","events_url":"https://api.github.com/users/rails-api/events{/privacy}","received_events_url":"https://api.github.com/users/rails-api/received_events","type":"Organization","site_admin":false},"repo":{"id":2889230,"name":"active_model_serializers","full_name":"rails-api/active_model_serializers","owner":{"login":"rails-api","id":2820360,"avatar_url":"https://avatars.githubusercontent.com/u/2820360?v=3","gravatar_id":"","url":"https://api.github.com/users/rails-api","html_url":"https://github.com/rails-api","followers_url":"https://api.github.com/users/rails-api/followers","following_url":"https://api.github.com/users/rails-api/following{/other_user}","gists_url":"https://api.github.com/users/rails-api/gists{/gist_id}","starred_url":"https://api.github.com/users/rails-api/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rails-api/subscriptions","organizations_url":"https://api.github.com/users/rails-api/orgs","repos_url":"https://api.github.com/users/rails-api/repos","events_url":"https://api.github.com/users/rails-api/events{/privacy}","received_events_url":"https://api.github.com/users/rails-api/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rails-api/active_model_serializers","description":"ActiveModel::Serializer implementation and Rails hooks","fork":false,"url":"https://api.github.com/repos/rails-api/active_model_serializers","forks_url":"https://api.github.com/repos/rails-api/active_model_serializers/forks","keys_url":"https://api.github.com/repos/rails-api/active_model_serializers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rails-api/active_model_serializers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rails-api/active_model_serializers/teams","hooks_url":"https://api.github.com/repos/rails-api/active_model_serializers/hooks","issue_events_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/events{/number}","events_url":"https://api.github.com/repos/rails-api/active_model_serializers/events","assignees_url":"https://api.github.com/repos/rails-api/active_model_serializers/assignees{/user}","branches_url":"https://api.github.com/repos/rails-api/active_model_serializers/branches{/branch}","tags_url":"https://api.github.com/repos/rails-api/active_model_serializers/tags","blobs_url":"https://api.github.com/repos/rails-api/active_model_serializers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rails-api/active_model_serializers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rails-api/active_model_serializers/git/refs{/sha}","trees_url":"https://api.github.com/repos/rails-api/active_model_serializers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rails-api/active_model_serializers/statuses/{sha}","languages_url":"https://api.github.com/repos/rails-api/active_model_serializers/languages","stargazers_url":"https://api.github.com/repos/rails-api/active_model_serializers/stargazers","contributors_url":"https://api.github.com/repos/rails-api/active_model_serializers/contributors","subscribers_url":"https://api.github.com/repos/rails-api/active_model_serializers/subscribers","subscription_url":"https://api.github.com/repos/rails-api/active_model_serializers/subscription","commits_url":"https://api.github.com/repos/rails-api/active_model_serializers/commits{/sha}","git_commits_url":"https://api.github.com/repos/rails-api/active_model_serializers/git/commits{/sha}","comments_url":"https://api.github.com/repos/rails-api/active_model_serializers/comments{/number}","issue_comment_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/comments{/number}","contents_url":"https://api.github.com/repos/rails-api/active_model_serializers/contents/{+path}","compare_url":"https://api.github.com/repos/rails-api/active_model_serializers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rails-api/active_model_serializers/merges","archive_url":"https://api.github.com/repos/rails-api/active_model_serializers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rails-api/active_model_serializers/downloads","issues_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues{/number}","pulls_url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls{/number}","milestones_url":"https://api.github.com/repos/rails-api/active_model_serializers/milestones{/number}","notifications_url":"https://api.github.com/repos/rails-api/active_model_serializers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rails-api/active_model_serializers/labels{/name}","releases_url":"https://api.github.com/repos/rails-api/active_model_serializers/releases{/id}","created_at":"2011-12-01T06:39:26Z","updated_at":"2015-08-11T18:30:01Z","pushed_at":"2015-08-12T02:26:06Z","git_url":"git://github.com/rails-api/active_model_serializers.git","ssh_url":"git@github.com:rails-api/active_model_serializers.git","clone_url":"https://github.com/rails-api/active_model_serializers.git","svn_url":"https://github.com/rails-api/active_model_serializers","homepage":"","size":5415,"stargazers_count":2886,"watchers_count":2886,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":655,"mirror_url":null,"open_issues_count":147,"forks":655,"open_issues":147,"watchers":2886,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1028"},"html":{"href":"https://github.com/rails-api/active_model_serializers/pull/1028"},"issue":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1028"},"comments":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1028/comments"},"review_comments":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1028/comments"},"review_comment":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/1028/commits"},"statuses":{"href":"https://api.github.com/repos/rails-api/active_model_serializers/statuses/5d5715a285182e6661021285407116839a9f2d4b"}}}}