Class: Locomotive::EditableFile

Inherits:
EditableElement show all
Defined in:
app/models/locomotive/editable_file.rb

Instance Attribute Summary

Attributes inherited from EditableElement

#block_name, #block_priority, #label

Instance Method Summary collapse

Methods inherited from EditableElement

#_type, #add_current_locale, #block_label, #by_priority, #disabled?, #page, #page_id, #path, #slug

Instance Method Details

#contentString

Note:

This method is not used for the rendering, only for the back-office

Returns the url or the path to the uploaded file if it exists. Otherwise returns the default url.

Returns:

  • (String)

    The url or path of the file


25
26
27
# File 'app/models/locomotive/editable_file.rb', line 25

def content
  self.source? ? self.source.url : self.default_source_url
end

#default_source_urlObject

fields ##


10
# File 'app/models/locomotive/editable_file.rb', line 10

field :default_source_url, localize: true

#remove_source=(value) ⇒ Object


31
32
33
34
# File 'app/models/locomotive/editable_file.rb', line 31

def remove_source=(value)
  self.source_will_change! # notify the page to run the callbacks for that element
  super
end

#sourceObject

behaviours ##


5
# File 'app/models/locomotive/editable_file.rb', line 5

mount_uploader 'source', EditableFileUploader