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
class Device < Panko::Serializer
attributes :id, :name
has_many :lights, serializer: LightSerializer
has_many :fans, serializer: FanSerializer
has_many :curtains, serializer: CurtainSerializer
end
now every device need not have all three, some might have just a fan and a light, some might have just a light.
I don't want to display empty arrays every single time. How do I selectively hide them if the array size is zero? I tried adding if: -> { object.fans.count > 0 } but that didn't seem to work, I still got an empty array.
The text was updated successfully, but these errors were encountered:
Say I have a serializer like this :
now every device need not have all three, some might have just a fan and a light, some might have just a light.
I don't want to display empty arrays every single time. How do I selectively hide them if the array size is zero? I tried adding if: -> { object.fans.count > 0 } but that didn't seem to work, I still got an empty array.
The text was updated successfully, but these errors were encountered: