dalpo / carrierwave_globalize Goto Github PK
View Code? Open in Web Editor NEWUse Globalize to manage Carrierwave translated fields :gem:
License: MIT License
Use Globalize to manage Carrierwave translated fields :gem:
License: MIT License
It seems like this plugin doesn't have an equivalent mount_translated_uploaders
for mount_uploaders
. It would be great to be able to handle an arbitrary number of translated files using that feature of carrierwave.
this method does not work. Even f.input :remove_attachment does not work. How to implement it?
I am using a gem 'rails_admin_globalize_field' which provides globalization feature for rails admin.But image fields is showing as text input instead of file upload per locale.Can you please look into for support.
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?
The following method has an issue:
def _translations_mounter(column)
@_translations_mounter ||= {}
(@_translations_mounter[Globalize.locale.to_sym] ||= {})[column] ||=
::CarrierWave::Mount::Mounter.new(self, column)
end
We need to change Carrierwave::Mount::Mounter to Carrierwave::Mounter
Reference for solution: neo4jrb/carrierwave-neo4j#11
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.