Module: Paperclip::Globalize3::Attachment
- Defined in:
- lib/paperclip/globalize3/attachment.rb
Overview
Prepend to the paperclip ‘Attachment` class to transparently read and write your attachments in context of the current locale using globalize.
E.g. ‘my_model.my_attachment` returns a different attachment when your current locale is ’en’ compared to when your current locale is ‘de’.
Requires a :locale interpolation for your paperclip attachment(s) and the respective columns to be translated.
Instance Method Summary collapse
Instance Method Details
#assign(uploaded_file) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/paperclip/globalize3/attachment.rb', line 14 def assign(uploaded_file) @file = Paperclip.io_adapters.for(uploaded_file, @options[:adapter_options]) ensure_required_accessors! ensure_required_validations! if @file.assignment? clear(*only_process, locales: Globalize.locale) # [paperclip-globalize3] only clear current locale if @file.nil? nil else assign_attributes post_process_file reset_file_if_original_reprocessed end else nil end end |
#clear(*args) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/paperclip/globalize3/attachment.rb', line 33 def clear(*args) = args. styles_to_clear = args if styles_to_clear.any? queue_some_for_delete(*styles_to_clear, ) else queue_all_for_delete() @queued_for_write = {} @errors = {} end end |