I have the carrier wave gem installed and I added a background worker to it (carrierwave_backgrounder gem`). The issue is now when I upload a photo it shows an empty box where the photo should be.
Photos model:
mount_uploader :image, ImageUploader
process_in_background :image
store_in_background :image
image_uploader.rb:
include CarrierWave::ImageOptimizer
include CarrierWave::MiniMagick
include ::CarrierWave::Backgrounder::Delay
/initializers/carrierwave_backgrounder.rb:
CarrierWave::Backgrounder.configure do |c|
c.backend :sidekiq, queue: :carrierwave
end
Migration:
class AddTempToUser < ActiveRecord::Migration
def change
add_column :users, :avatar_tmp, :string
end
Photos controller:
def create
@photo = Photo.create(photo_params)
@photo.user = current_user
if @photo.valid? and @photo.save!
flash[:notice] = "Successfully created photos."
redirect_to :back
else
flash[:notice] = @photo.errors.messages[:base].first
render :action => 'new'
end
end
Server logs:
Jul 31 17:28:07 areyoutaken app/web.1: Processing by PhotosController#create as JS
Jul 31 17:28:07 areyoutaken app/web.1: Processing by PhotosController#create as JS
Jul 31 17:28:07 areyoutaken app/web.1: Parameters: {"utf8"=>"✓", "authenticity_token"=>"xhE8IGs/FLF+cJvMWMJeC5sUFkGk76Xe6SoWzT8v1Pg=", "photo"=>{"image"=>#<ActionDispatch::Http::UploadedFile:0x007f7e80662960 @tempfile=#<Tempfile:/tmp/RackMultipart20150801-3-eiq7px>, @original_filename="love.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"photo[image]\"; filename=\"love.jpg\"\r\nContent-Type: image/jpeg\r\n">}}
Jul 31 17:28:07 areyoutaken app/web.1: Parameters: {"utf8"=>"✓", "authenticity_token"=>"xhE8IGs/FLF+cJvMWMJeC5sUFkGk76Xe6SoWzT8v1Pg=", "photo"=>{"image"=>#<ActionDispatch::Http::UploadedFile:0x007f7e80662960 @tempfile=#<Tempfile:/tmp/RackMultipart20150801-3-eiq7px>, @original_filename="love.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"photo[image]\"; filename=\"love.jpg\"\r\nContent-Type: image/jpeg\r\n">}}
Aucun commentaire:
Enregistrer un commentaire