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: tags_controller.rb
    path of file: ./repos/bootcamp/app/controllers/api
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

class API::TagsController < API::BaseController
  skip_before_action :require_login_for_api

  def index
    @tags = taggable_type.all_tags
  end

  def update
    tag = ActsAsTaggableOn::Tag.find(params[:id])
    same_na
    
  def update
    tag = ActsAsTaggableOn::Tag.find(params[:id])
    same_name_tag = ActsAsTaggableOn::Tag.find_by(name: tag_params[:name])

    if same_name_tag && replace_tagging_tags_with(same_name_tag)
      head :ok
    elsif tag.update(tag_params)
      head :ok
    else
      head :bad_request
    end