vendredi 29 décembre 2017

Rails 5 - How to get serializable_hash for activerecord?

In rails 5, I am trying to get a data in serializable_hash format. First set of data format is in correct but second set of data is in different format. The Comment module works like parent and children format, one comment has_many comments by adding parent_comment_id.

For parent comment, now data is {id: 77, name: "l1", verified: true, category: "Movie", slug: "l1", …}

For child comment, data is coming like {id: 78, name: "l2", category_id: 61, …}

Here I need to get second set of data for comments as same as first format. I have tried using serializable_hash but it supports only single row. How can I achieve this for all comments(has_many association)?

Aucun commentaire:

Enregistrer un commentaire