rails4 carrierwave + S3 adding new image version

I have a rails4 app, profile images are uploaded with carrierwave and served by S3.

I used to have one image version (base_thumb) for resizing. Now I'm trying to add user_thumb, but if I change the code from profile.avatar.url(:base_thumb) to profile.avatar.url(:user_thumb) then the image is not displayed to users who created profile earlier since that image version is not on S3.

How can I solve this issue?

version :base_thumb do
  process :resize_to_fit => [85, 85]
end

version :user_thumb do
  process :resize_to_fit => [40, 40]
end

Answers


You'll need to create new versions of each different size. Carrierwave has a method for this.

You can read the doc here: https://github.com/carrierwaveuploader/carrierwave#recreating-versions

but essentially you will run something like

Profile.find_each do |profile|
  profile.avatar.recreate_versions! if profile.avatar?
end

Need Your Help

Retractable UITabBarController / UINavigationController

iphone objective-c uitabbarcontroller

I'm looking to implement something similar to the Mashable app article view. When clicked through to read an article and begin to scroll down the Navigation controller slides up off screen and the ...

Sub Projects in one ASP.NET solution not able to share Master page

asp.net master-pages web-application-project

I've been researching this added with banging my head against the wall. I have a WAP solution that will contain several web projects. I want to use one shared site.master page file for all projects.