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: invitations_controller.rb
    path of file: ./repos/dwellingly-app/app/controllers
    
    the code of the file until where you have to start completion: class InvitationsController < Devise::InvitationsController
  before_action :authorize
    
  def create
    self.resource = invite_resource

    yield resource if block_given?

    if resource.errors.empty?
      render json: resource, status: :created
    else
      render json: resource.errors, status: :unprocessable_entity
    end