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

require 'va_profile/demographics/service'

module Mobile
  module V0
    class PreferredNamesController < ApplicationController
      before_action { authoriz
    
      def update
        preferred_name = VAProfile::Models::PreferredName.new preferred_name_params

        if preferred_name.valid?
          service.save_preferred_name preferred_name

          head :no_content
        else
          raise Common::Exceptions::ValidationErrors, preferred_name
        end