scinote-web/app/serializers/checklist_serializer.rb
2022-05-11 15:51:26 +02:00

18 lines
497 B
Ruby

# frozen_string_literal: true
class ChecklistSerializer < ActiveModel::Serializer
include Rails.application.routes.url_helpers
attributes :id, :name, :urls
has_many :checklist_items, serializer: ChecklistItemSerializer
def urls
return {} if object.destroyed?
{
delete_url: step_checklist_path(object.step, object),
update_url: step_checklist_path(object.step, object),
create_item_url: step_checklist_checklist_items_path(object.step, object)
}
end
end