I want to use a serializer that displays non-null attributes
class PersonSerializer < ActiveModel::Serializer attributes :id, :name, :phone, :address, :email end
Is it possible.
Many thanks.
Decision:
class PersonSerializer < ActiveModel::Serializer attributes :id, :name, :phone, :address, :email def attributes hash = super hash.each {|key, value| if value.nil? hash.delete(key) end } hash end end
ruby-on-rails serialization notnull attributes
Nabila hamdaoui
source share