instance method variant=

Ruby on Rails 5.2.8.1

Since v4.1.16

Available in: v4.1.16 v4.2.9 v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

variant=(variant)

Sets the \variant for template.

Parameters

variant req
Source
# File actionpack/lib/action_dispatch/http/mime_negotiation.rb, line 87
      def variant=(variant)
        variant = Array(variant)

        if variant.all? { |v| v.is_a?(Symbol) }
          @variant = ActiveSupport::ArrayInquirer.new(variant)
        else
          raise ArgumentError, "request.variant must be set to a Symbol or an Array of Symbols. " \
            "For security reasons, never directly set the variant to a user-provided value, " \
            "like params[:variant].to_sym. Check user-provided value against a whitelist first, " \
            "then set the variant: request.variant = :tablet if params[:variant] == 'tablet'"
        end
      end

Defined in actionpack/lib/action_dispatch/http/mime_negotiation.rb line 87 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionDispatch::Http::MimeNegotiation

Type at least 2 characters to search.

↑↓ navigate · open · esc close