Invalidate cache in CarrierWave uploader?
@const-cloudinary đang làm issue này rồi.
Từ ngày 17/11/2019.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
Hi, I having strange issue that I found many people struggle with through out issues, but I havent found how to make it using carrierwave. My problem is that if I have cloudinary carrierwave uploader on field in model and currently that field is nil and I upload new image using just simple_form form submit - it appears in cloudinary dashboard and as actual field in model so I can see uploaded image on site. Issue occurs when I want to update existing image on model - after model.update_attributes call with say logo parameter from form submitted, I see new image occurs in dashboard and old one is gone, however, my model still having old image in its field, so that I see only old image on site.
For example, my model Comany is Neo4j one, and in it is only that:
class Company
...
property :logo
mount_uploader :logo, CompanyLogoUploader
...
end
CompanyLogoUploader:
class CompanyLogoUploader < CarrierWave::Uploader::Base
include Cloudinary::CarrierWave
process :convert => 'jpg'
if Rails.env.development?
process :tags => ['env.development']
end
version :large do
process :resize_to_fit => [500, 500, :north]
end
version :medium do
process :resize_to_fit => [140, 140, :north]
end
version :small do
process :resize_to_fit => [80, 80, :north]
end
version :tiny do
process :resize_to_fill => [20, 20, :north]
end
end
Now, if I have company model without logo and upload new one, all is great and here what I see as logo:
[2] pry(main)> Company.find('f0cfdf56-0f72-4184-affb-b37ee5fe097e').logo
=> #<CompanyLogoUploader:0x0055971c014d58
@file=
#<Cloudinary::CarrierWave::CloudinaryFile:0x0055971c010e10
@filename="spikbsjvpx9tkgi78c3w.jpg",
@format="jpg",
@identifier="spikbsjvpx9tkgi78c3w.jpg",
@public_id="spikbsjvpx9tkgi78c3w",
@resource_type="image",
@storage_type=nil,
@uploader=#<CompanyLogoUploader:0x0055971c014d58 ...>,
@version=nil>,
@model=
#<Company uuid: f0cfdf56-0f72-4184-affb-b37ee5fe097e, active_deals_count: 1, company_size: , created_at: 2015-12-17T21:01:24+00:00, deals_count: 1, description: Online HR services: payroll, benefits, and everything else, fundraising_stage: , jobs_count: 1, logo: https://res-3.cloudinary.com/davsupw1h/image/upload/spikbsjvpx9tkgi78c3w.jpg, name: Gusto, negativity_percentage: 0.0, ratings_count: 105, recommendation_percentage: 0.9714285714285714, reviews_count: 35, score: 9.6, screenshot: https://res-2.cloudinary.com/davsupw1h/image/upload/v1451872564/c8ve6qbmu2sqkws3hi2b.jpg, slug: gusto, updated_at: 2018-07-30T12:11:10+00:00, url: http://gusto.com/, url_ref: false, votes_score: 0, wilson_score: 9.4>,
@mounted_as=:logo,
@original_filename="spikbsjvpx9tkgi78c3w.jpg",
@public_id="spikbsjvpx9tkgi78c3w",
@stored_public_id="spikbsjvpx9tkgi78c3w",
@stored_version=nil>
[3] pry(main)> Company.find('f0cfdf56-0f72-4184-affb-b37ee5fe097e').logo.url(:medium)
=> "https://res3.cloudinary.com/davsupw1h/image/upload/c_fit,h_140,w_140/spikbsjvpx9tkgi78c3w.jpg"
It appears in dashboard with url: "https://res.cloudinary.com/davsupw1h/image/upload/v1532952671/spikbsjvpx9tkgi78c3w.jpg"
Now, If I'll change this image to smth else, here's updated debug:
[4] pry(main)> Company.find('f0cfdf56-0f72-4184-affb-b37ee5fe097e').logo
=> #<CompanyLogoUploader:0x0055971be73148
@file=
#<Cloudinary::CarrierWave::CloudinaryFile:0x0055971be6cdc0
@filename="spikbsjvpx9tkgi78c3w.jpg",
@format="jpg",
@identifier="spikbsjvpx9tkgi78c3w.jpg",
@public_id="spikbsjvpx9tkgi78c3w",
@resource_type="image",
@storage_type=nil,
@uploader=#<CompanyLogoUploader:0x0055971be73148 ...>,
@version=nil>,
@model=
#<Company uuid: f0cfdf56-0f72-4184-affb-b37ee5fe097e, active_deals_count: 1, company_size: , created_at: 2015-12-17T21:01:24+00:00, deals_count: 1, description: Online HR services: payroll, benefits, and everything else, fundraising_stage: , jobs_count: 1, logo: https://res-3.cloudinary.com/davsupw1h/image/upload/spikbsjvpx9tkgi78c3w.jpg, name: Gusto, negativity_percentage: 0.0, ratings_count: 105, recommendation_percentage: 0.9714285714285714, reviews_count: 35, score: 9.6, screenshot: https://res-2.cloudinary.com/davsupw1h/image/upload/v1451872564/c8ve6qbmu2sqkws3hi2b.jpg, slug: gusto, updated_at: 2018-07-30T12:17:41+00:00, url: http://gusto.com/, url_ref: false, votes_score: 0, wilson_score: 9.4>,
@mounted_as=:logo,
@original_filename="spikbsjvpx9tkgi78c3w.jpg",
@public_id="spikbsjvpx9tkgi78c3w",
@stored_public_id="spikbsjvpx9tkgi78c3w",
@stored_version=nil>
[5] pry(main)> Company.find('f0cfdf56-0f72-4184-affb-b37ee5fe097e').logo.url(:medium)
=> "https://res-3.cloudinary.com/davsupw1h/image/upload/c_fit,h_140,w_140/spikbsjvpx9tkgi78c3w.jpg"
Whereas new image that got updated in dashboard has url "https://res.cloudinary.com/davsupw1h/image/upload/v1532953062/spikbsjvpx9tkgi78c3w.jpg" - version is changed.
So my question is next - should I pass version somehow in image uploader, and how/where?
If yes then why does carrierwave integration by default does not using version and rely on caching? Can I turn it off somehow, in uploader, in cloudinary initializer? Thanks.
- Ngôn ngữ chính
- Ruby
- Star
- 420
- Fork
- 282
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của cloudinary/cloudinary_gem
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
cloudinary/cloudinary_gem#597 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 52/100
cloudinary/cloudinary_gem#591 · 3 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
cloudinary/cloudinary_gem#582 · 1 bình luận ·
-
404's when fetching .eml files (from Action Mailbox)Có thể làm lại được @rnamba-cloudinary đã nhận 400 ngày trước và không có pull request nào đang mở. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
cloudinary/cloudinary_gem#581 · 1 bình luận ·
-
BlobKey, MirrorService and Sidekiq 8 are incompatibleCó thể làm lại được @const-cloudinary đã nhận 541 ngày trước và không có pull request nào đang mở. Đang mở
cloudinary/cloudinary_gem#573 · 3 bình luận · 1 người được giao ·
Tất cả issue của cloudinary/cloudinary_gem
Issue tương tự
-
area: ci benchmark build developer-experience difficulty: easy dx enhancement github-actions good first issue hacktoberfest help wanted performance quality rank: 8 kyu ruby tech: ruby
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
flisk-sh/flisk-labs#22 ·
-
1.severity: security
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
15-minutes 5-minutes algorithm any-language beginner-friendly c cpp csharp easy go good first issue hacktoberfest help wanted java javascript kotlin python rust swift typescript
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
Huerte/algo-solutions-python#260 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
internal
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Kong/developer.konghq.com#8080 ·
Maintainer thường phản hồi trong vòng 1 ngày