Giter Club home page Giter Club logo

Comments (6)

yosiat avatar yosiat commented on August 22, 2024

Hi @VetriVellore ,

By using the different key you mean:

  • while reading the object - the key is comments, you want it to access object.feedback instead of comments
  • JSON output - set key "feedback" for "comments" relationship

This is for JSON output:

class PostSerializer < Panko::Serializer
	has_many :comments, serializer: CommentSerializer, name: :feedback
end

And the JSON output will be:

{
	"feedback": [/* array of comments here */]
}

from panko_serializer.

VetriVellore avatar VetriVellore commented on August 22, 2024

Thanks Yosiat! Very helpful.

from panko_serializer.

VetriVellore avatar VetriVellore commented on August 22, 2024

@yosiat does name: work with has_one?

from panko_serializer.

mikebaldry avatar mikebaldry commented on August 22, 2024

Why don't you try it? I can see from the tests that it is supported:

https://github.com/yosiat/panko_serializer/blob/master/spec/panko/serializer_spec.rb#L309

from panko_serializer.

mikebaldry avatar mikebaldry commented on August 22, 2024

I can see the documentation doesn't mention name being supported on has_one and has_many. This could be improved (also, should probably update with info about serializing a hash)

from panko_serializer.

yosiat avatar yosiat commented on August 22, 2024

@VetriVellore has_one should work with name property as @mikebaldry said.

I'll update the documentation soon, closing the issue for now.
If the has_one + name doesn't work for you please update

from panko_serializer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.