{"action":"created","issue":{"url":"https://api.github.com/repos/jsonapi-rb/jsonapi-rails/issues/75","repository_url":"https://api.github.com/repos/jsonapi-rb/jsonapi-rails","labels_url":"https://api.github.com/repos/jsonapi-rb/jsonapi-rails/issues/75/labels{/name}","comments_url":"https://api.github.com/repos/jsonapi-rb/jsonapi-rails/issues/75/comments","events_url":"https://api.github.com/repos/jsonapi-rb/jsonapi-rails/issues/75/events","html_url":"https://github.com/jsonapi-rb/jsonapi-rails/issues/75","id":281559093,"node_id":"MDU6SXNzdWUyODE1NTkwOTM=","number":75,"title":"Specify class when including relationships","user":{"login":"KidA001","id":8673088,"node_id":"MDQ6VXNlcjg2NzMwODg=","avatar_url":"https://avatars3.githubusercontent.com/u/8673088?v=4","gravatar_id":"","url":"https://api.github.com/users/KidA001","html_url":"https://github.com/KidA001","followers_url":"https://api.github.com/users/KidA001/followers","following_url":"https://api.github.com/users/KidA001/following{/other_user}","gists_url":"https://api.github.com/users/KidA001/gists{/gist_id}","starred_url":"https://api.github.com/users/KidA001/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KidA001/subscriptions","organizations_url":"https://api.github.com/users/KidA001/orgs","repos_url":"https://api.github.com/users/KidA001/repos","events_url":"https://api.github.com/users/KidA001/events{/privacy}","received_events_url":"https://api.github.com/users/KidA001/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-12-12T22:25:21Z","updated_at":"2018-07-31T14:52:33Z","closed_at":null,"author_association":"NONE","body":"In my controller I have\r\n```\r\nmodule API\r\n  module V1\r\n    class ProjectsController < API::V1::ApplicationController\r\n\r\n      # GET /projects\r\n      def index\r\n        render jsonapi: Project.all,\r\n               class: { Project: API::V1::SerializableProject },\r\n               include: params[:include]\r\n      end\r\n```\r\n\r\nIn my Serializer I have\r\n```\r\nmodule API\r\n  module V1\r\n    class SerializableProject < JSONAPI::Serializable::Resource\r\n      type 'projects'\r\n\r\n      attributes :name, :job_number\r\n\r\n      has_many :companies\r\n    end\r\n  end\r\nend\r\n```\r\n\r\nWhen I pass the `include` params with `GET /projects?include=companies`, I get `undefined method 'new' for nil:NilClass`. I'm assuming because it can't find `API::V1::SerializableCompany`\r\n\r\nHow am I supposed to specify the class for all includes? This was a simplified example, but some of my Models have multiple relationships."},"comment":{"url":"https://api.github.com/repos/jsonapi-rb/jsonapi-rails/issues/comments/409249693","html_url":"https://github.com/jsonapi-rb/jsonapi-rails/issues/75#issuecomment-409249693","issue_url":"https://api.github.com/repos/jsonapi-rb/jsonapi-rails/issues/75","id":409249693,"node_id":"MDEyOklzc3VlQ29tbWVudDQwOTI0OTY5Mw==","user":{"login":"beauby","id":2215778,"node_id":"MDQ6VXNlcjIyMTU3Nzg=","avatar_url":"https://avatars3.githubusercontent.com/u/2215778?v=4","gravatar_id":"","url":"https://api.github.com/users/beauby","html_url":"https://github.com/beauby","followers_url":"https://api.github.com/users/beauby/followers","following_url":"https://api.github.com/users/beauby/following{/other_user}","gists_url":"https://api.github.com/users/beauby/gists{/gist_id}","starred_url":"https://api.github.com/users/beauby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beauby/subscriptions","organizations_url":"https://api.github.com/users/beauby/orgs","repos_url":"https://api.github.com/users/beauby/repos","events_url":"https://api.github.com/users/beauby/events{/privacy}","received_events_url":"https://api.github.com/users/beauby/received_events","type":"User","site_admin":false},"created_at":"2018-07-31T14:52:32Z","updated_at":"2018-07-31T14:52:32Z","author_association":"MEMBER","body":"@kapso @siepet If you look at the code history, it used to be that way. The reasons it was modified:\r\n1. It introduces possible inconsistencies (say you're requesting a post and their comments, and the authors of those – a same author could be serialized by two possibly different serializers).\r\n2. It makes debugging harder because it is not clear what serializer was used and how it was chosen.\r\n\r\nNote that in most use-cases, you would use the controller-level hooks to provide a static or dynamic hash, i.e.\r\n```ruby\r\ndef jsonapi_class\r\n  @jsonapi_classes ||= { \r\n    # ...\r\n  }\r\nend\r\n```"}}
{"actor":{"display_login":"beauby"}}