instance method
variant=
Ruby on Rails 5.2.8.1
Since v4.1.16Signature
variant=(variant)
Sets the \variant for template.
Parameters
-
variantreq
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