Commit 2606f1b3

mo khan <mo@mokhan.ca>
2013-03-06 04:24:24
add image_tmp column and try store_in_background processing to try to speed up uploads.
1 parent c4a8918
app/models/photo.rb
@@ -3,27 +3,28 @@ class Photo < ActiveRecord::Base
   belongs_to :creation
   validates :image,  :presence => true
   mount_uploader :image, PhotoUploader
-  process_in_background :image
+  #process_in_background :image
+  store_in_background :image
 
   include Rails.application.routes.url_helpers
   def to_jq_upload
     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,
-        "delete_type" => "DELETE"
+        :name => read_attribute(:image),
+        :size => image.size,
+        :url => image.url,
+        :thumbnail_url => image.thumb.url,
+        :delete_url => id,
+        :delete_type => "DELETE"
       }
     else
       {
-        "name" => read_attribute(:image),
-        "size" => image.size,
-        "url" => image.url,
-        "thumbnail_url" => image.url,
-        "delete_url" => id,
-        "delete_type" => "DELETE"
+        :name => read_attribute(:image),
+        :size => image.size,
+        :url => image.url,
+        :thumbnail_url => image.url,
+        :delete_url => id,
+        :delete_type => "DELETE"
       }
     end
   end
config/initializers/carrierwave_backgrounder.rb
@@ -0,0 +1,8 @@
+CarrierWave::Backgrounder.configure do |c|
+  c.backend :delayed_job, queue: :carrierwave
+  # c.backend :resque, queue: :carrierwave
+  # c.backend :sidekiq, queue: :carrierwave
+  # c.backend :girl_friday, queue: :carrierwave
+  # c.backend :qu, queue: :carrierwave
+  # c.backend :qc
+end
db/migrate/20130306034251_add_photo_tmp_column_to_photos.rb
@@ -0,0 +1,5 @@
+class AddPhotoTmpColumnToPhotos < ActiveRecord::Migration
+  def change
+    add_column :photos, :image_tmp, :string
+  end
+end
db/schema.rb
@@ -11,7 +11,7 @@
 #
 # It's strongly recommended to check this file into your version control system.
 
-ActiveRecord::Schema.define(:version => 20130221134059) do
+ActiveRecord::Schema.define(:version => 20130306034251) do
 
   create_table "active_admin_comments", :force => true do |t|
     t.integer  "resource_id",   :null => false
@@ -129,6 +129,7 @@ ActiveRecord::Schema.define(:version => 20130221134059) do
     t.string   "image"
     t.datetime "created_at"
     t.datetime "updated_at"
+    t.string   "image_tmp"
   end
 
   add_index "photos", ["creation_id"], :name => "index_photos_on_creation_id"