metamaps--metamaps/app/serializers/mapping_serializer.rb
2016-09-13 15:21:14 +08:00

18 lines
465 B
Ruby

class MappingSerializer < ActiveModel::Serializer
attributes :id,
:xloc,
:yloc,
:created_at,
:updated_at,
:mappable_id,
:mappable_type
has_one :user, serializer: UserSerializer
has_one :map, serializer: MapSerializer
def filter(keys)
keys.delete(:xloc) unless object.mappable_type == 'Topic'
keys.delete(:yloc) unless object.mappable_type == 'Topic'
keys
end
end