File icon giver/getter/whatever
It gets the file extension then looks up that extension in a dir full of files named extension.png
if none is found, unknown.png is used
<% extension = File.extname(attachment.filename).gsub(/\./, "") # get a file icon icon_path = nil Dir.entries("#{RAILS_ROOT}/public/images/filetypes").each do |entry| entry_extension = File.extname(entry) if entry.gsub(entry_extension, "") === extension icon_path = "/images/filetypes/" + entry break end end icon_path = "/images/filetypes/unknown.png" if icon_path.nil? %> <%= image_tag icon_path %> <span class="attachment_name"><%= attachment.filename %></span><br />