scinote-web/app/serializers/api/v1/activity_serializer.rb

19 lines
648 B
Ruby
Raw Normal View History

# frozen_string_literal: true
module Api
module V1
class ActivitySerializer < ActiveModel::Serializer
type :activities
2018-10-07 17:49:11 +08:00
attributes :id, :type_of, :message
belongs_to :project, serializer: ProjectSerializer
belongs_to :experiment, serializer: ExperimentSerializer,
2018-10-07 17:49:11 +08:00
if: -> { object.experiment.present? }
belongs_to :my_module, key: :task,
serializer: TaskSerializer,
class_name: 'MyModule',
if: -> { object.my_module.present? }
belongs_to :user, serializer: UserSerializer
end
end
end