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: tour.rb
    path of file: ./repos/phishin/app/models
    
    the code of the file until where you have to start completion: class Tour < ApplicationRecord
  has_many :shows, dependent: :nullify

  extend FriendlyId
  friendly_id :name, use: 
    
  def as_json_api
    {
      id:,
      name:,
      shows_count:,
      slug:,
      starts_on: starts_on.iso8601,
      ends_on: ends_on.iso8601,
      shows: shows.sort_by(&:date).as_json,
      updated_at: updated_at.iso8601
    }
  end