Skip to content

Photo metadata is nil until after AR callbacks have run #499

Description

@kris

Describe the bug in a sentence or two.

I'm trying to extract colors from an uploaded image, following the docs on utilizing cloudinary_transformation and an after_save on the model. Unfortunately, metadata seems to always be nil. Once the after_save callback has finished, then source.metadata is populated. This seems like a misplaced lifecycle callback or something.

Issue Type (Can be multiple)

  • Build - Cannot install or import the SDK
  • Performance - Performance issues
  • Behaviour - Functions are not working as expected (such as generate URL)
  • Documentation - Inconsistency between the docs and behaviour
  • Other (Specify)

Steps to reproduce

class PhotoUploader < CarrierWave::Uploader::Base
  include Cloudinary::CarrierWave
  cloudinary_transformation image_metadata: true, colors: true
end

class Photo < ApplicationRecord
  mount_uploader :source, PhotoUploader

  after_save :extract_colors

  def extract_colors
    # `source.metadata` is `nil`
  end
end

Environment and Libraries (fill in the version numbers)

  • Cloudinary Ruby SDK version - 1.23.0
  • Ruby Version - 3.1.2
  • Rails Version - 7.0.4
  • Carrierwave - 2.2.2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions