Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache with recreate versions #2070

Closed
vincentcordel opened this issue Nov 26, 2016 · 1 comment
Closed

Cache with recreate versions #2070

vincentcordel opened this issue Nov 26, 2016 · 1 comment

Comments

@vincentcordel
Copy link

Hey there,

Here's my uploader:

class PersonPhotoUploader < CarrierWave::Uploader::Base

  after :store, :delete_old_tmp_file

  def store_dir
    "people/#{model.id}"
  end

  def extension_white_list
    %w(jpg jpeg gif png)
  end

  process resize_to_fit: [400, 400]

  version :tiny do
    process :resize_to_fill => [50, 50]
  end

  version :thumbnail do
  	process :resize_to_fill => [100, 100]
  end

  version :medium do
  	process :resize_to_fill => [200, 200]
  end

  def filename
    "person_photo.#{file.extension}" if original_filename
  end

	# remember tmp file
  def cache!(new_file)
    super
    @old_tmp_file = new_file
  end

  # delete tmp file
  def delete_old_tmp_file(dummy)
    @old_tmp_file.try :delete
  end

end

When trying to recreate versions (using delayed job), I get an error (line 32: super).

If I remove the method cache!, it works fine but when redisplaying the form (if there's an error), I can't get the cached file.

I'm sure there must be a way to fix this but I don't know how. Any ideas?

Thanks!

  • Vincent
@mshibuya
Copy link
Member

mshibuya commented May 2, 2019

Please use StackOverflow for the support request, thanks.

@mshibuya mshibuya closed this as completed May 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants