module ActionDispatch::Http::MimeNegotiation

def variant=(variant)

Sets the \variant for template.
def variant=(variant)
  if variant.is_a?(Symbol)
    @variant = [variant]
  elsif variant.nil? || variant.is_a?(Array) && variant.any? && variant.all?{ |v| v.is_a?(Symbol) }
    @variant = variant
  else
    raise ArgumentError, "request.variant must be set to a Symbol or an Array of Symbols, not a #{variant.class}. " \
      "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