I'm using rmagick
to create a montage. After I submit a request, it gets stuck in an infinite loop, and the request continues to create the same image over, and over, until I manually restart server:
class LineItem < ActiveRecord::Base
has_many :images, as: :imageable, dependent: :destroy
after_save :process
private
def process
image_list = Magick::ImageList.new(*self.photos.split(','))
montage = image_list.montage do
self.geometry = "182x182+6+6"
self.tile = "4x3"
end
name = "#{self.id}_#{Time.now}.jpg"
montage.write(name)
images.build(source: File.open(name))
save!
end
Any idea why this is happening, or how to debug it?