Sha256: d660231b166f53a0b020212f197a8eb0de116596aa78e960d8e25d227d0e104a
Contents?: true
Size: 1.08 KB
Versions: 30
Compression:
Stored size: 1.08 KB
Contents
module Locomotive class EditableFile < EditableElement ## behaviours ## mount_uploader 'source', EditableFileUploader replace_field 'source', ::String, true ## fields ## field :default_source_url, localize: true field :resize_format ## callbacks ## after_initialize :init_localized_source ## methods ## # Returns the url or the path to the uploaded file # if it exists. Otherwise returns the default url. # # @note This method is not used for the rendering, only for the back-office # # @return [String] The url or path of the file # def content self.source? ? self.source.url : self.default_source_url end alias :content= :source= def remove_source=(value) self.source_will_change! # notify the page to run the callbacks for that element super end private def init_localized_source # FIXME: the source of the element is not correctly set for the first time (certainly because the source is localized) attributes['source'] = {} unless self.persisted? end end end
Version data entries
30 entries across 30 versions & 1 rubygems