I have the following code:
def label_file_type(type)
label =
case type.to_s
when ['.jpg', '.jpeg', '.png'].include?(type) then
content_tag(:span, 'Imagem', class: ['label', 'picture'])
when ['.mp3'].include?(type) then
content_tag(:span, 'Áudio', class: 'label audio')
when ['.txt', '.pdf', '.doc', '.docx', '.odt'].include?(type) then
content_tag(:span, 'Documento', class: 'label document')
else
content_tag(:span, 'Indefinido', class: 'label')
end
end
This is a helper. For some reason, the only output I get on the screen is that of the else. It is as if the instruction is ignoring all comparisons and jumping straight to the last. Can anyone explain me why this does not work that way?