Sha256: acdd602966e40f179a3e2a22eabc3125cd80686d911d7d1b50c790551aa4c561

Contents?: true

Size: 426 Bytes

Versions: 3

Compression:

Stored size: 426 Bytes

Contents

module Petrie
  class Page < ActiveRecord::Base
    extend FriendlyId
    friendly_id :title, use: [:scoped, :slugged], scope: :parent

    acts_as_nested_set

    def should_generate_new_friendly_id?
      title_changed?
    end

    def top_ancestor
      return parent.top_ancestor if parent
      self
    end

    def top_ancestor?
      self == top_ancestor
    end

    def home?
      slug == 'home'
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
petrie-0.1.4 app/models/petrie/page.rb
petrie-0.1.3 app/models/petrie/page.rb
petrie-0.1.2 app/models/petrie/page.rb