module Ecom module Core class SiteCrewsController < ApplicationController before_action :set_service, only: %i[update] def index crew_ids = Ecom::Core::SiteCrew.where(site_id: params[:id], status: 'Active').select(:crew_id) crews = Ecom::Core::Crew.where(id: crew_ids) serialized = ActiveModelSerializers::SerializableResource.new(crews) render json: { success: true, data: serialized } end def update data = @service.update(params) serialized = ActiveModelSerializers::SerializableResource.new(data[:data]) render json: { success: true, data: serialized } end private def set_service @service = SiteCrewService.new end end end end