Skip to content

Hanami serialization example is wrong #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
luciusgone opened this issue Jul 3, 2017 · 2 comments
Closed

Hanami serialization example is wrong #14

luciusgone opened this issue Jul 3, 2017 · 2 comments

Comments

@luciusgone
Copy link
Contributor

I suppose there is an example that is wrong about hanami framework.
the file is located at source/guides/serialization/rendering.html.md.

The example says:

module API::Controllers::Posts
  include API::Action
  include JSONAPI::Hanami::Action

  expose :url_helpers

  class Create
    # ...
    @url_helpers = routes  # Will be available inside serializable resources.

    self.data = posts
    self.include = [:author, comments: [:author]]
    self.fields  = { users: [:name, :email],
                     posts: [:title, :content] }
  end
end

It should be like this:

module API::Controllers::Posts
  class Create
    include API::Action
    include JSONAPI::Hanami::Action

    expose :url_helpers

    def call(params)
      #...
      @url_helpers = routes  # Will be available inside serializable resources.

      self.data = posts
      self.include = [:author, comments: [:author]]
      self.fields  = { users: [:name, :email],
                       posts: [:title, :content] }
    end
  end
end
@beauby
Copy link
Member

beauby commented Jul 3, 2017

Hi @luciusgone – you are right indeed. Would you mind opening a PR to fix it?

@beauby
Copy link
Member

beauby commented Jul 4, 2017

Fixed by #15.

@beauby beauby closed this as completed Jul 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants