diff --git a/app/models/upload.rb b/app/models/upload.rb index d2049d6..a55e81e 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -1,17 +1,23 @@ -class Upload < ActiveRecord::Base - attr_accessible :upload - has_attached_file :upload + 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" - } - 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..3f56878 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" %> $(function () {