Module: PagesCore::PageModel::Attachments

Extended by:
ActiveSupport::Concern
Included in:
Page
Defined in:
app/models/concerns/pages_core/page_model/attachments.rb

Instance Method Summary collapse

Instance Method Details

#attachmentsObject



24
25
26
# File 'app/models/concerns/pages_core/page_model/attachments.rb', line 24

def attachments
  super.in_locale(locale)
end

#attachments?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'app/models/concerns/pages_core/page_model/attachments.rb', line 28

def attachments?
  attachments.any?
end

#filesObject



41
42
43
# File 'app/models/concerns/pages_core/page_model/attachments.rb', line 41

def files
  page_files
end

#page_filesObject



32
33
34
# File 'app/models/concerns/pages_core/page_model/attachments.rb', line 32

def page_files
  super.in_locale(locale)
end

#page_files_attributes=(attrs) ⇒ Object



36
37
38
39
# File 'app/models/concerns/pages_core/page_model/attachments.rb', line 36

def page_files_attributes=(attrs)
  ids = page_files.map(&:id)
  super(attrs.reject { |a| a["_destroy"] && ids.exclude?(a["id"]) })
end