You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: queries_controller.rb
    path of file: ./repos/motor-admin-rails/app/controllers/motor
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

module Motor
  class QueriesController < ApiBaseController
    wrap_parameters :data, except: %i[include fields]

    load_and_authorize_resource :query, only: %i[index show update destroy]

    before_action :build_query, only: :create
    authorize_resource :query, only: :create

    def in
    
    def create
      if Motor::Queries::Persistance.name_already_exists?(@query)
        render json: { errors: [{ source: 'name', detail: 'Name already exists' }] }, status: :unprocessable_entity
      else
        ApplicationRecord.transaction do
          Motor::Queries::Persistance.assign_or_create_api_config!(@query)
          @query.save!
        end

        Motor::Configs::WriteToFile.call

        render json: { data: Motor::ApiQuery::BuildJson.call(@query, params, current_ability) }
      end