Commit 9ca061a2

mo khan <mo@mokhan.ca>
2013-12-30 00:34:08
do not include file size in json response because it is not stable. fixes #12.
1 parent ccef5ed
Changed files (3)
app/controllers/photos_controller.rb
@@ -7,7 +7,7 @@ class PhotosController < ApplicationController
     @photos = @creation.photos
     respond_to do |format|
       format.html # index.html.erb
-      format.json { render json: {files: @photos.map { |p| p.to_jq_upload } }.to_json }
+      format.json { render json: { files: @photos.map { |photo| photo.to_jq_upload } } }
     end
   end
 
app/models/photo.rb
@@ -10,7 +10,6 @@ class Photo < ActiveRecord::Base
     if image.thumb.url && image.thumb.url != image.thumb.default_url
       {
         :name => read_attribute(:image),
-        :size => image.size,
         :url => image.url,
         :thumbnail_url => image.thumb.url,
         :delete_url => id,
@@ -19,7 +18,6 @@ class Photo < ActiveRecord::Base
     else
       {
         :name => read_attribute(:image),
-        :size => image.size,
         :url => image.url,
         :thumbnail_url => image.url,
         :delete_url => id,
app/uploaders/photo_uploader.rb
@@ -4,20 +4,21 @@ class PhotoUploader < CarrierWave::Uploader::Base
   include CarrierWave::MimeTypes
   include ::CarrierWave::Backgrounder::Delay
 
-  def store_dir
-    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
-  end
-
   process :set_content_type
 
   version :large do 
     process :resize_to_fit => [570, 630]
     process :watermark
   end
+
   version :thumb, :from_version => :large do
     process :resize_to_fill => [260, 180]
   end
 
+  def store_dir
+    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
+  end
+
   def watermark
     return if model.watermark.blank?
     manipulate! do |image|