You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classCategoryController < ApplicationControllerdefmain_menu# take one of the following two linesroots=Category.rootsroots=Category.roots.first.subtreerenderjson: roots,each_serializer: MenuSerializer# , include: children <- won't work tooendend
classChildSerializer# here only "name" should be rendered, but ALL attributes (created_at, attribute_to_exclude_from_children_only,..) are rendered too... attribute(:name)# I set here a breakpoint, which was called once, but seems not kick in to render properlyattribute(:children),each_serializer: ChildSerializerend
what I also tried (maybe some weired things too, but I am quite desperate
Only :ccc and :ddd gets rendered, but with ALL attributes (created_at,...)
Can someone help me to get this going? Thank you VERY MUCH in advance
Environment
ActiveModelSerializers Version (commit ref if not on tag):
Output of ruby -e "puts RUBY_DESCRIPTION": ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin20]
OS Type & Version: Darwin 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:07:06 PST 2021; root:xnu-7195.81.3~1/RELEASE_X86_64 x86_64
Integrated application and version (e.g., Rails, Grape, etc): Rails "6.1.3.1"
Backtrace
(e.g., provide any applicable backtraces from your application)
So a category should be serialized by a menu serializer?
And the category's children are not relations?
How many levels deep are you trying to serialize?
Expected behavior vs actual behavior
Serialize nested attributes (and exclude some attributes from rendering)
I can see the children in json output but the nested Serializer is not
Steps to reproduce
install gem
ancestry
for polymorphic / self referencing models
model:
create some Categories
controller:
Serializers:
what I also tried (maybe some weired things too, but I am quite desperate
Only
:ccc
and:ddd
gets rendered, but with ALL attributes (created_at,...)Can someone help me to get this going? Thank you VERY MUCH in advance
Environment
ActiveModelSerializers Version (commit ref if not on tag):
Output of
ruby -e "puts RUBY_DESCRIPTION"
:ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin20]
OS Type & Version:
Darwin 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:07:06 PST 2021; root:xnu-7195.81.3~1/RELEASE_X86_64 x86_64
Integrated application and version (e.g., Rails, Grape, etc):
Rails "6.1.3.1"
Backtrace
(e.g., provide any applicable backtraces from your application)
Additonal helpful information
(e.g., Gemfile.lock, configurations, PR containing a failing test, git bisect results)
The text was updated successfully, but these errors were encountered: