Skip to content

mount_translated_uploader always populates with string of "Uploader" object #8

@ghost

Description

Hi there,

I've followed the instructions, and boiled down, the code in use is:

class Bob < ActiveRecord::Base
  translates :message, :button_text, :message_footer, :image_landing_url, :square_image
  extend CarrierwaveGlobalize
  mount_translated_uploader :square_image, SquareImageUploader
end

Uploader:

class SquareImageUploader < CarrierWave::Uploader::Base
  include CarrierWave::MiniMagick
  storage :file
  
  process resize_and_crop: 800

  private

   def resize_and_crop(size)
    manipulate! do |image|
      if image[:width] < image[:height]
        remove = ((image[:height] - image[:width])/2).round
        image.shave("0x#{remove}")
      elsif image[:width] > image[:height]
        remove = ((image[:width] - image[:height])/2).round
        image.shave("#{remove}x0")
      end
      image.resize("#{size}x#{size}")
      image
    end
  end

end

The problem happens when the resulting form (relevant snippet):

= f.fields_for :translations, bob_translations do |ft|
        .col-md-4
          .panel.panel-default
            .panel-heading
              = translation_locale_name(ft.object.locale)
            .panel-body
              = ft.hidden_field :locale
              = ft.file_field :square_image

The form has multipart also set.

But all of the values posted to the fields being saved as string representations of the upload file object, like "#ActionDispatch::Http::UploadedFile:0x00007fd5d44c99e0" - which is not useful.

Any hits for where this might not be working?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions