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: registrations_controller.rb
    path of file: ./repos/consuldemocracy/app/controllers/users
    
    the code of the file until where you have to start completion: class Users::RegistrationsController < Devise::RegistrationsController
  prepend_before_action :authenticate_scope!,
                        only: [:edit, :update, :destroy, :finish_signup, :do_finish_signup]
    
  def check_username
    if User.find_by username: params[:username]
      render json: { available: false,
                     message: t("devise_views.users.registrations.new.username_is_not_available") }
    else
      render json: { available: true,
                     message: t("devise_views.users.registrations.new.username_is_available") }
    end