79178064

Date: 2024-11-11 14:42:12
Score: 1.5
Natty:
Report link

Check why this doesn't work

  def should_update_dominant_color?
    image.attached? && 
    (saved_change_to_attribute?('image_attachment_id') || image.attachment&.saved_change_to_blob_id?)
  end

maybe there is some other way to check if the image was changed.

You can try to use some other callback like "before_save" and check if an image was changed and set some flag. And later use "after_commit" and that flag to run your logic.

In general I think your code should be working but difficult to say why not. What gem are you using for attachments?

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Low reputation (0.5):
Posted by: Igor Kasyanchuk