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
How to iterate through an array with relations?
And how to pass through "columns"-method (example below) one serializer deeper?
ANY help appreciated (thank you)
Steps to reproduce
classCategoryhas_many:categories# self referencingattribute_reader:name# nested arrays with Categories grouped in chunks of piecesdefcolumns# how can I use a serializer on these array of arrays. Somehow this method is not able to serialize. The only way it works is the 'approach_one', but it will respond with ALL available attributes, where I only need name (and some others[[Category.find(1),Category.find(2),Category.find(2)][Category.find(4),Category.find(5),Category.find(6)]]endend
classColumnSerializerattribute:grouped_children,key: :approach_one,serializer: CategoryMenuColumnsSerializer# outputs everything of "colums"-method. But does not use Serializer in any way# another approachattribute:grouped_childrendo |serializer|
serializer.grouped_children.eachdo |column|
CategoryMenuColumnsSerializer.new(column)endendendclassCategoryMenuColumnsSerializer < ActiveModel::Serializerattribute:name,key: :titleend
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)
Expected behavior vs actual behavior
How to iterate through an array with relations?
And how to pass through "columns"-method (example below) one serializer deeper?
ANY help appreciated (thank you)
Steps to reproduce
This is what I get:
Expected result
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: