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

Have to reload AR model when saving base64 photos. #62

Closed
bramski opened this issue Aug 22, 2017 · 5 comments
Closed

Have to reload AR model when saving base64 photos. #62

bramski opened this issue Aug 22, 2017 · 5 comments
Assignees

Comments

@bramski
Copy link

bramski commented Aug 22, 2017

Seeing a bit of odd behavior.
Gemfile.lock:

carrierwave (1.1.0)
      activemodel (>= 4.0.0)
      activesupport (>= 4.0.0)
      mime-types (>= 1.16)
    carrierwave-base64 (2.5.3)
      carrierwave (>= 0.8.0)
      mime-types (~> 3.0)

Model looks like:

 mount_base64_uploader :original_photo, PatronPhotoUploader

In a spec I have the following:

describe "#original_photo=" do
    let(:new_photo) { build(:patron_photo, original_photo: original_photo) }
    context "base64 encoded" do
      let(:original_photo) { valid_base64_image }
      it "accepts base64-encoded images" do
        expect(new_photo).to be_valid
        expect { new_photo.save! }.not_to raise_error
        expect(new_photo.original_photo).to be_present
      end
    end
  end

However, the check for presence fails.

1) PatronPhoto#original_photo= base64 encoded accepts base64-encoded images
     Failure/Error: expect(new_photo.original_photo).to be_present
       expected `#<PatronPhotoUploader:0x007f8ef4a441f8 @model=#<PatronPhoto id: 3, original_photo: "ukpu42doyhyfyov8y...Storage:0x007f8ef3ddf098 @uploader=#<PatronPhotoUploader:0x007f8ef4a441f8 ...>>, @transformation={}>.present?` to return true, got false

If I reload the active record before checking for presence it succeeds.

@bbugh
Copy link

bbugh commented Oct 17, 2018

@bramski did you sort out a workaround for this? We do a bunch of client params processing in a method far away from having access to the model itself, so we don't have an easy way to reload the model unless we reload every model.

@y9v
Copy link
Owner

y9v commented Oct 22, 2018

@bramski @bbugh Can you share some details on the versions of carrierwave and rails gems you use?

I've tried reproducing the bug without any success: ab8fdf1

@bbugh
Copy link

bbugh commented Oct 22, 2018

We're on Rails 5.2, Carrierwave 1.2.3. I'm using Cloudinary as the CDN which has some code that extends Carrierwave, so it's possible that the extended code is breaking it. @bramski were you using Cloudinary as well?

@y9v
Copy link
Owner

y9v commented Nov 1, 2018

I'm closing this, until I can reproduce this bug. Feel free to re-open it if it is still actual

@y9v y9v closed this as completed Nov 1, 2018
@yourtallness
Copy link

yourtallness commented Mar 31, 2019

@y9v I can confirm this happens with carrierwave, cloudinary & carrierwave-base64 on rails 4.2.11.1 as well.
Need to reload for the presence check to work.

@y9v y9v reopened this Apr 1, 2019
@y9v y9v closed this as completed Jun 25, 2024
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

4 participants