vol1ura/Sat_9am_5km

View on GitHub
app/controllers/api/internal/athletes_controller.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
# frozen_string_literal: true

module API
  module Internal
    class AthletesController < ApplicationController
      def update
        athlete = Athlete.joins(:user).find_by!(user: { telegram_id: params[:telegram_id] })
        athlete.update!(athlete_params)
        head :ok
      end

      rescue_from(ActiveRecord::InvalidForeignKey) { head :not_acceptable }

      private

      def athlete_params
        params.require(:athlete).permit(:club_id, :event_id)
      end
    end
  end
end