Class: Spina::Resource

Inherits:
ApplicationRecord show all
Extended by:
Mobility
Defined in:
app/models/spina/resource.rb

Instance Method Summary collapse

Methods inherited from ApplicationRecord

#to_partial_path

Instance Method Details

#order_by_optionsObject



28
29
30
31
32
33
# File 'app/models/spina/resource.rb', line 28

def order_by_options
  [
    [Spina::Page.human_attribute_name(:title), "title"],
    [Spina::Page.human_attribute_name(:created_at), "created_at"]
  ]
end

#pagesObject



11
12
13
14
15
16
17
18
19
20
# File 'app/models/spina/resource.rb', line 11

def pages
  case order_by
  when "title"
    super.joins(:translations).where(spina_page_translations: {locale: I18n.locale}).order("spina_page_translations.title")
  when "created_at"
    super.order(:created_at)
  else
    super.order(:position)
  end
end

#update_resource_pagesObject



22
23
24
25
26
# File 'app/models/spina/resource.rb', line 22

def update_resource_pages
  if previous_changes[:slug]
    ResourcePagesUpdateJob.perform_later(id)
  end
end