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

Question regarding the product images uploading. #103

Open
imgarylai opened this issue May 25, 2020 · 3 comments
Open

Question regarding the product images uploading. #103

imgarylai opened this issue May 25, 2020 · 3 comments

Comments

@imgarylai
Copy link

imgarylai commented May 25, 2020

In our store, there are products without any variants. In this case, if I upload an image to these kinds of products. I got the error message.

The error message I got was

Module::DelegationError
signed_id delegated to attachment, but attachment is nil

Let me put a link to show the rest of the error message: https://sentry.io/share/issue/f09bf17e537a40768d0e25610acee431/

On the other hand, if a product has at least one variant, the image uploading works fine. However, mailchimp_image_url is still nil. It causes the image that doesn't properly show on the MailChimp.

And also is it possible to sync each of variant to Mailchimp as a single item? This might be another issue tho.

@imgarylai
Copy link
Author

My workaround is by changing

def active_storage_url
return "" unless images.any?
Rails.application.routes.url_helpers.rails_blob_url(images.first&.attachment)
end

to

def active_storage_url
  if images.any? && images.first&.attachment.attached?
    Rails.application.routes.url_helpers.rails_blob_url(images.first&.attachment)
  else
    ""
  end
end

Everything works fine, but I think there must be a better way to fix this.

@TheodoreCha
Copy link

@imgarylai Many thanks for sharing

@ronzalo
Copy link

ronzalo commented Dec 30, 2020

@imgarylai thanks for the snippet, can be merged into the gem?

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

3 participants