Image and document uploads via file content_type

jamesperet 10 jaren geleden
bovenliggende
commit
9024882fde
2 gewijzigde bestanden met toevoegingen van 9 en 1 verwijderingen
  1. 4 0
      .gitignore
  2. 5 1
      app/views/uploads/show.html.erb

+ 4 - 0
.gitignore

@@ -56,5 +56,9 @@ Icon
56 56
 Network Trash Folder
57 57
 Temporary Items
58 58
 .apdisk
59
+
59 60
 # Ignore application configuration
60 61
 /config/application.yml
62
+
63
+# Ignore File Uploads
64
+/public/uploads

+ 5 - 1
app/views/uploads/show.html.erb

@@ -7,7 +7,11 @@
7 7
 
8 8
 <p>
9 9
   <strong>File:</strong><br>
10
-  <%= image_tag @upload.file.to_s if @upload.file != nil %>
10
+  <% if @upload.file.file.content_type == 'image/jpeg' || @upload.file.file.content_type == 'image/png' %>
11
+ 	<%= image_tag @upload.file.to_s if @upload.file != nil %>
12
+  <% else %>
13
+  	<%= link_to @upload.title, @upload.file.to_s %>
14
+  <% end %>
11 15
 </p>
12 16
 
13 17
 <p>