From 3eb252c63f652b8f7164020f93ee8c5820d1d86f Mon Sep 17 00:00:00 2001
From: Mike Bethany
Date: Mon, 10 Nov 2014 13:34:26 -0500
Subject: [PATCH 1/3] Fix thumbnail not showing
---
app/models/upload.rb | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/app/models/upload.rb b/app/models/upload.rb
index d2049d6..426c475 100644
--- a/app/models/upload.rb
+++ b/app/models/upload.rb
@@ -1,6 +1,11 @@
class Upload < ActiveRecord::Base
attr_accessible :upload
- has_attached_file :upload
+ has_attached_file :upload,
+ styles: {
+ original: "600x600>",
+ thumbnail: "40x40#"
+ }
+
include Rails.application.routes.url_helpers
@@ -10,7 +15,8 @@ def to_jq_upload
"size" => read_attribute(:upload_file_size),
"url" => upload.url(:original),
"delete_url" => upload_path(self),
- "delete_type" => "DELETE"
+ "delete_type" => "DELETE",
+ "thumbnail_url" => upload.url(:thumbnail)
}
end
From 3f2e25436a7f7ac2f1f73cf29fda62e75e6ee0ab Mon Sep 17 00:00:00 2001
From: Mike Bethany
Date: Mon, 10 Nov 2014 13:48:34 -0500
Subject: [PATCH 2/3] Moved upload and download templates out of index
---
app/models/upload.rb | 38 +++++++-------
app/views/uploads/_download_template.html | 29 +++++++++++
app/views/uploads/_upload_template.html | 31 ++++++++++++
app/views/uploads/index.html.erb | 62 +----------------------
4 files changed, 81 insertions(+), 79 deletions(-)
create mode 100644 app/views/uploads/_download_template.html
create mode 100644 app/views/uploads/_upload_template.html
diff --git a/app/models/upload.rb b/app/models/upload.rb
index 426c475..a55e81e 100644
--- a/app/models/upload.rb
+++ b/app/models/upload.rb
@@ -1,23 +1,23 @@
-class Upload < ActiveRecord::Base
- attr_accessible :upload
- has_attached_file :upload,
- styles: {
- original: "600x600>",
- thumbnail: "40x40#"
- }
+ class Upload < ActiveRecord::Base
+ attr_accessible :upload
+ has_attached_file :upload,
+ styles: {
+ original: "600x600>",
+ thumbnail: "40x40#"
+ }
- include Rails.application.routes.url_helpers
+ include Rails.application.routes.url_helpers
- def to_jq_upload
- {
- "name" => read_attribute(:upload_file_name),
- "size" => read_attribute(:upload_file_size),
- "url" => upload.url(:original),
- "delete_url" => upload_path(self),
- "delete_type" => "DELETE",
- "thumbnail_url" => upload.url(:thumbnail)
- }
- end
+ def to_jq_upload
+ {
+ "name" => read_attribute(:upload_file_name),
+ "size" => read_attribute(:upload_file_size),
+ "url" => upload.url(:original),
+ "delete_url" => upload_path(self),
+ "delete_type" => "DELETE",
+ "thumbnail_url" => upload.url(:thumbnail)
+ }
+ end
-end
+ end
diff --git a/app/views/uploads/_download_template.html b/app/views/uploads/_download_template.html
new file mode 100644
index 0000000..378ca27
--- /dev/null
+++ b/app/views/uploads/_download_template.html
@@ -0,0 +1,29 @@
+
+
diff --git a/app/views/uploads/_upload_template.html b/app/views/uploads/_upload_template.html
new file mode 100644
index 0000000..bccc8d2
--- /dev/null
+++ b/app/views/uploads/_upload_template.html
@@ -0,0 +1,31 @@
+
+
\ No newline at end of file
diff --git a/app/views/uploads/index.html.erb b/app/views/uploads/index.html.erb
index 36c1bcc..64085bb 100644
--- a/app/views/uploads/index.html.erb
+++ b/app/views/uploads/index.html.erb
@@ -51,66 +51,8 @@
};
-
-
-
-
+<%== render "upload_template" %>
+<%== render "download_template" %>
-<%== render "upload_template" %>
-<%== render "download_template" %>
+<%= render "upload_template" %>
+<%= render "download_template" %>
$(function () {