mini_magick_processing_error while seeding database in rails

1k Views Asked by At

So I've been using rails for some time and seeding seemed to work smoothly until now. Now, every time that I try to seed my database, the following error pops-up:

ActiveRecord::RecordInvalid: La validación falló: Mainimages main image translation missing: es.errors.messages.mini_magick_processing_error

The thing is that I do not have any validations on my Mainimages at all. Furthermore, I don't know why it is asking for a translation of the main image. I've read some similar problems and according to them re-installing the gem or installing Imagemagick solves the problem. The thing is that neither work. Also, I've seeded my database multiple times before, even with mainimage in place and just now this error started appearing, which really confuses me.

Here is a snip of seeds.rb

Event.create!(
name: "event_1",
place_name: "test_place",
organizer_id: 2,
mainimages_attributes:[{main_image: File.open(File.join(Rails.root, 'test.jpg'))}]
)

Here is the Mainimage model:

class Mainimage < ApplicationRecord
  belongs_to :event, optional: true
  mount_uploader :main_image, MainImageUploader
end

and the uploader:

class MainImageUploader < CarrierWave::Uploader::Base

  include CarrierWave::MiniMagick
  storage :fog

  version :thumb do
    process resize_to_limit: [150, 150]
    process quality: 100
  end

  version :not_so_thumb do
    process resize_to_limit: [1000, 800]
    process quality: 100
  end

  version :large do
    process resize_to_limit: [1652,1115]
    process quality: 100
  end

  def crop
    if model.crop_x.present?
      resize_to_limit(600, 400)
      manipulate! do |img|
        x = model.crop_x.to_i
        y = model.crop_y.to_i
        w = model.crop_w.to_i
        h = model.crop_h.to_i
        img.crop!(x, y, w, h)
      end
    end
  end

  def extension_whitelist
    %w(jpg jpeg gif png)
  end

end
0

There are 0 best solutions below