Search code examples
ruby-on-railsruby-on-rails-plugins

Trouble with using Fleximage plugin and getting .operate to save changes


I'm using the Fleximage plugin to manage image files in my rails project.

This must be dirt simple, but I can't figure it out for the life of me

I'm trying to create a thumbnail record. Initially I copy the master image record, and then I try to operate on it to make some changes but the changes are never saved to the database?? I tried to output the length of the image data to see if it changed and at all and it was totally unaffected. This seems like it should work??

  thumbnail = Visualization.create(self.attributes)
  thumbnail.picture_id = self.id
  thumbnail.style = 'thumbnail'
  thumbnail.save!
  puts "Length = " + thumbnail.image_file_data.to_s.length.to_s
  thumbnail.operate do |image|
    image.resize '100x100'
    image.shadow :color      => 'black',    # or color(0, 0, 0)
      :background => 'white',    # or color(255, 255, 255)
      :blur       => 8,
      :offset     => '3x3',
      :opacity    => 0.75    
  end      
  thumbnail.save!
  puts "Length = " + thumbnail.image_file_data.to_s.length.to_s

Solution

  • I figured this out

    Instead of operate I needed to use operate!