Repository: rails/rails
File: activerecord/lib/active_record/railtie.rb (Ruby)

Code before:
      end
    end

    initializer "active_record.set_filter_attributes" do
      ActiveSupport.on_load(:active_record) do
        self.filter_attributes += Rails.application.config.filter_parameters
      end
    end

    initializer "active_record.configure_message_verifiers" do
      config.before_initialize do |app|
        secret = ActiveRecord::Base.signed_id_verifier_secret
        secret_generator = if secret
          secret.respond_to?(:call) ? -> (_) { secret.call } : -> (_) { secret }
        else
          -> (_) { Rails.application.key_generator.generate_key("active_record/signed_id") }
        end
        legacy_options = { secret_generator: secret_generator, digest: "SHA256", serializer: JSON, url_safe: true }.compact

        if app.config.active_record.use_legacy_signed_id_verifier == :generate_and_verify
          app.message_verifiers.prepend { |salt| legacy_options if salt == "active_record/signed_id" }
        elsif app.config.active_record.use_legacy_signed_id_verifier == :verify
          app.message_verifiers.rotate { |salt| legacy_options if salt == "active_record/signed_id" }
        else
          raise ArgumentError, "Unknown value for ActiveRecord::Base.use_legacy_signed_id_verifier: #{app.config.active_record.use_legacy_signed_id_verifier}"
        end
      end
    end

    initializer "active_record.set_signed_id_verifier" do
      config.after_initialize do |app|
        ActiveSupport.on_load(:active_record) do
          self.message_verifiers = app.message_verifiers
        end
      end
    end

    initializer "active_record.generated_token_verifier" do
      config.after_initialize do |app|
        ActiveSupport.on_load(:active_record) do
          self.generated_token_verifier ||= app.message_verifier("active_record/token_for")
        end
      end
    end

    initializer "active_record_encryption.configuration" do |app|
      ActiveSupport.on_load(:active_record_encryption) do
        ActiveRecord::Encryption.configure(
          primary_key: app.credentials.dig(:active_record_encryption, :primary_key),
          deterministic_key: app.credentials.dig(:active_record_encryption, :deterministic_key),
          key_derivation_salt: app.credentials.dig(:active_record_encryption, :key_derivation_salt),

Review comment (suggestion):
This should be `elsif app.config.active_record.use_legacy_signed_id_verifier`.

The idea is, eventually, we want to use just `app.message_verifiers` without `legacy_options`.  So we want users to be able to set `app.config.active_record.use_legacy_signed_id_verifier` to false (and, eventually, it might default to false).

Code after:
        end
      end
    end

    initializer "active_record.set_filter_attributes" do
      ActiveSupport.on_load(:active_record) do
        self.filter_attributes += Rails.application.config.filter_parameters
      end
    end

    initializer "active_record.configure_message_verifiers" do |app|
      ActiveRecord.message_verifiers = app.message_verifiers

      use_legacy_signed_id_verifier = app.config.active_record.use_legacy_signed_id_verifier
      legacy_options = { digest: "SHA256", serializer: JSON, url_safe: true }

      if use_legacy_signed_id_verifier == :generate_and_verify
        app.message_verifiers.prepend { |salt| legacy_options if salt == "active_record/signed_id" }
      elsif use_legacy_signed_id_verifier == :verify
        app.message_verifiers.rotate { |salt| legacy_options if salt == "active_record/signed_id" }
      elsif use_legacy_signed_id_verifier
        raise ArgumentError, "Unrecognized value for config.active_record.use_legacy_signed_id_verifier: #{use_legacy_signed_id_verifier.inspect}"
      end
    end

    initializer "active_record.generated_token_verifier" do
      config.after_initialize do |app|
        ActiveSupport.on_load(:active_record) do
          self.generated_token_verifier ||= app.message_verifier("active_record/token_for")
        end
      end
    end

    initializer "active_record_encryption.configuration" do |app|
      ActiveSupport.on_load(:active_record_encryption) do
        ActiveRecord::Encryption.configure(
          primary_key: app.credentials.dig(:active_record_encryption, :primary_key),
          deterministic_key: app.credentials.dig(:active_record_encryption, :deterministic_key),
          key_derivation_salt: app.credentials.dig(:active_record_encryption, :key_derivation_salt),
          **app.config.active_record.encryption
        )

        auto_filtered_parameters = ActiveRecord::Encryption::AutoFilteredParameters.new(app)
        auto_filtered_parameters.enable if ActiveRecord::Encryption.config.add_to_filter_parameters
      end

      ActiveSupport.on_load(:active_record) do
        # Support extended queries for deterministic attributes and validations
        if ActiveRecord::Encryption.config.extend_queries
          ActiveRecord::Encryption::ExtendedDeterministicQueries.install_support
          ActiveRecord::Encryption::ExtendedDeterministicUniquenessValidator.install_support