Skip to content

Instantly share code, notes, and snippets.

@geranyl
Last active August 29, 2015 14:04
Show Gist options
  • Save geranyl/f2004a51486411687c25 to your computer and use it in GitHub Desktop.
Save geranyl/f2004a51486411687c25 to your computer and use it in GitHub Desktop.
One line Carrierwave regeneration of images
For an uploader mounted on a model
Model eg:
class Post < ActiveRecord::Base
attr_accessible :title, :body, :published, :image, :tags, :author, :description, :image_cache, :remove_image, :tag_ids, :tags_attributes
has_many :post_tags
has_many :tags, through: :post_tags
mount_uploader :image, AssetUploader
end
In command line:
rails console
Post.all.each{|post| post.image.recreate_versions!}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment