Sha256: 410a755edacf956da13868239de754dac8461b47dd9c7abbc85b33eb29cd95f0

Contents?: true

Size: 659 Bytes

Versions: 22

Compression:

Stored size: 659 Bytes

Contents

module Spina
  class NavigationItem < ApplicationRecord
    belongs_to :navigation, touch: true
    belongs_to :page

    has_ancestry

    scope :regular_pages, -> { joins(:page).where(spina_pages: {resource_id: nil}) }
    scope :sorted, -> { order('spina_navigation_items.position') }
    scope :live, -> { joins(:page).where(spina_pages: {draft: false, active: true}) }
    scope :in_menu, -> { joins(:page).where(spina_pages: {show_in_menu: true}) }
    scope :active, -> { joins(:page).where(spina_pages: {active: true}) }

    validates :page, uniqueness: {scope: :navigation}

    delegate :menu_title, :materialized_path, :draft?, to: :page
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
spina-2.12.0 app/models/spina/navigation_item.rb
spina-2.11.0 app/models/spina/navigation_item.rb
spina-2.10.0 app/models/spina/navigation_item.rb
spina-2.9.1 app/models/spina/navigation_item.rb
spina-2.9.0 app/models/spina/navigation_item.rb
spina-2.8.1 app/models/spina/navigation_item.rb
spina-2.8.0 app/models/spina/navigation_item.rb
spina-2.7.0 app/models/spina/navigation_item.rb
spina-2.6.2 app/models/spina/navigation_item.rb
spina-2.6.1 app/models/spina/navigation_item.rb
spina-2.6.0 app/models/spina/navigation_item.rb
spina-2.5.0 app/models/spina/navigation_item.rb
spina-2.4.0 app/models/spina/navigation_item.rb
spina-2.3.5 app/models/spina/navigation_item.rb
spina-2.3.4 app/models/spina/navigation_item.rb
spina-2.3.3 app/models/spina/navigation_item.rb
spina-2.3.2 app/models/spina/navigation_item.rb
spina-2.3.1 app/models/spina/navigation_item.rb
spina-2.3.0 app/models/spina/navigation_item.rb
spina-2.2.0 app/models/spina/navigation_item.rb