Class: Cms::AbstractFileBlock
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Cms::AbstractFileBlock
- Defined in:
- app/models/cms/abstract_file_block.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
-
#file_size ⇒ Object
Exists here so FileBrowser can polymorphically call file_size on Page, Images, Files, etc.
-
#parent ⇒ Cms::Section
Return the parent section for this block.
- #path ⇒ Object
- #set_attachment_path ⇒ Object
- #set_attachment_section ⇒ Object
Class Method Details
.publishable? ⇒ Boolean
33 34 35 |
# File 'app/models/cms/abstract_file_block.rb', line 33 def self.publishable? true end |
.with_parent_id(parent_id) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'app/models/cms/abstract_file_block.rb', line 5 def self.with_parent_id(parent_id) if parent_id == 'all' where(true) # Empty scope for chaining else self.includes({:attachments => :section_node}) .references(:section_node) .where(["#{"cms_section_nodes"}.ancestry = ?", Section.find(parent_id).ancestry_path]) end end |
Instance Method Details
#file_size ⇒ Object
Exists here so FileBrowser can polymorphically call file_size on Page, Images, Files, etc.
25 26 27 |
# File 'app/models/cms/abstract_file_block.rb', line 25 def file_size file.size.round_bytes end |
#parent ⇒ Cms::Section
Return the parent section for this block.
20 21 22 |
# File 'app/models/cms/abstract_file_block.rb', line 20 def parent file.parent end |
#path ⇒ Object
29 30 31 |
# File 'app/models/cms/abstract_file_block.rb', line 29 def path file.url end |
#set_attachment_path ⇒ Object
37 38 39 40 41 |
# File 'app/models/cms/abstract_file_block.rb', line 37 def if @attachment_file_path && @attachment_file_path != .file_path .file_path = @attachment_file_path end end |
#set_attachment_section ⇒ Object
43 44 45 46 47 |
# File 'app/models/cms/abstract_file_block.rb', line 43 def if @attachment_section_id && @attachment_section_id != .section .section_id = @attachment_section_id end end |