carrierwave

Weird Characters encoding

心不动则不痛 提交于 2019-12-13 05:26:08
问题 I have a weird behaviour in my params whichare passed as utf-8 but the special characters are not well managed. Instead of 1 special character, I have 2 characters: the normal letter + the accent. Parameters: {"name"=>"Mylène.png", "_cardbiz_session"=>"be1d5b7a2f27c7c4979ac4c16fe8fc82", "authenticity_token"=>"9vmJ02DjgKYCpoBNUcWwUlpxDXA8ddcoALHXyT6wrnM=", "asset"=>{"file"=># < ActionDispatch::Http::UploadedFile:0x007f94d38d37d0 @original_filename="Mylène.png", @content_type="image/png",

Why CarrierWave image is not duplicated the second time?

南楼画角 提交于 2019-12-13 04:53:11
问题 I try to duplicate a record many time using this code : my_obj = Obj.find_by(id: params[:id]) new_obj = my_obj.dup I use CarrierWave to mount an image to my Obj class Obj < ActiveRecord::Base mount_uploader :image, ObjImageUploader end my first code above, duplicate the obj as well but it doesn't duplicate the image correctly, it shows instead something like Medium 2013 08 04 14354 , so i tried to fix this using new_obj = my_obj.dup new_obj.image = my_obj.image and now it works correctly, the

Carrierwave - destroy object only after mounted files have been deleted from storage

雨燕双飞 提交于 2019-12-13 04:29:15
问题 Carrierwave deletes files after the destruction of the object has been completed: after_commit :remove_avatar! :on => :destroy https://github.com/carrierwaveuploader/carrierwave I have a worker that deletes the files. If one of the workers timeout when deleting a file from S3 I lose track of the files on S3 and my bucket becomes a mess (since my object that had the mounted file is gone from my DB). How should I handle this? Directly call remove_avatar! before my object.destroy and then skip

carrierwave cache multiple files

一笑奈何 提交于 2019-12-13 03:18:57
问题 I use Carrierwave with Rails 5. I need to upload multiple images to some instance. But if validation is getting failed all images lost. I found and use image_cache for caching uploaded file, but it works only for single file upload. Is in Carrierwave way to cache multiple files for multiple files upload. Thanks. 回答1: SOLVED for Rails 5.1.4, Carrierwave 1.2.1 I did it without attr_accesor :images in view: = f.file_field :images, multiple: true = f.hidden_field :images_cache in controller: def

Rails activeadmin/carrierwave has_many photos relationship throwing mass-assignment exception

China☆狼群 提交于 2019-12-13 02:56:14
问题 I have a model BlogPost defined as class BlogPost < ActiveRecord::Base attr_accessible :title, :body, :photo, :photos_attributes, as: :admin has_many :photos, class_name: 'BlogPhoto', dependent: :destroy validates :body, :photo, :title, presence: true validates :title, uniqueness: true accepts_nested_attributes_for :photos, allow_destroy: true end from schema create_table "blog_posts", :force => true do |t| t.string "title" t.text "body" t.datetime "created_at", :null => false t.string "photo

Carrierwave not uploading - no error shown

自古美人都是妖i 提交于 2019-12-13 01:27:17
问题 I've been working on this all night and it makes no sense. I'm adapting an old photo web app to have albums in it. I made "fails" (basically images) a nested resource of albums. I am using carrierwave to upload files to an S3 bucket. the weird thing is: the upload works perfectly fine for the album model (album image), but it doesn't upload for the fail model. I don't see why it'd be a problem that it's a nested resource now. It's not a problem displaying it's that for some reason, it goes

carrierwave multiple uploader for single model

时光总嘲笑我的痴心妄想 提交于 2019-12-12 22:31:37
问题 I have created a gallery module with the help of this tutorial https://kolosek.com/carrierwave-upload-multiple-images/ and now I want to add one more image attribute has a master image to the same model. So I thot of creating one more uploader but I'm bit confused about how to call that the controller can anybody help me out? My code looks like this: MOdel Code: class Image < ApplicationRecord belongs_to :gallery mount_uploader :image, ImageUploader mount_uploader :avatar, AvatarUploader end

skip carrierwave Integirty and Processing validation

依然范特西╮ 提交于 2019-12-12 15:24:00
问题 I have white listed some of the extensions in the carrierwave uploader class def extension_white_list %w(doc docx) end In some cases I would like to skip the Integrity validation while saving a record. But as per their documentation validates_integrity_of validation exist by default. https://github.com/carrierwaveuploader/carrierwave/wiki/How-to%3A-Validate-uploads-with-Active-Record can anyone please tell me how to skip such validation ? 回答1: in uploaders/file_uploader.rb def extension_white

Getting Excon::Errors::SocketError while reading images from one S3 and to write to another?

北城以北 提交于 2019-12-12 10:39:29
问题 We have a staging server setup to use a different S3 bucket from our production server, but that requires us to manually sync the images between the buckets in order to see images on staging. As we have tens of thousands of images (growing daily), this is not viable. Is there anyway to configure Carrierwave to read images from our production S3, but write any new images to staging S3 (so as to not contaminate our production image store)? UPDATE : I've tried my hand at creating a custom

cleanup tmp directory with carrierwave

放肆的年华 提交于 2019-12-12 07:16:37
问题 I use carrierwave for my images upload, in my form i added a hidden field for caching like is described in documentation. = form_for @user, html: {multipart: true} do |f| %p = f.label :image, "your image" = f.file_field :image, id: "img" = f.hidden_field :image_cache but the problem is after uploading images and saving record, tmp directory still having all temporary/caching files. there is a way to clean up the tmp directory ? i found this post here but can't understand it as well, and there