Sha256: 8db078107e821fe720cd8286819cc694359acbf30600a0605b132e1dfea7f57f

Contents?: true

Size: 466 Bytes

Versions: 11

Compression:

Stored size: 466 Bytes

Contents

module Brightcontent
  class Page < ActiveRecord::Base
    acts_as_nested_set
    attr_accessible :body, :name, :parent_id

    validates_presence_of :name

    after_save :update_slug

    default_scope order('lft')

    def homepage?
      lft == 1
    end

    private

    def update_slug
      self.update_column(:slug, slug_name)
    end

    def slug_name
      homepage? ? "" : self_and_ancestors.map { |p| p.name.parameterize }.join("/")
    end

  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
brightcontent-pages-2.0.6 app/models/brightcontent/page.rb
brightcontent-pages-2.0.5 app/models/brightcontent/page.rb
brightcontent-pages-2.0.3 app/models/brightcontent/page.rb
brightcontent-pages-2.0.2 app/models/brightcontent/page.rb
brightcontent-pages-2.0.1 app/models/brightcontent/page.rb
brightcontent-pages-2.0.0.alpha6 app/models/brightcontent/page.rb
brightcontent-pages-2.0.0.alpha5 app/models/brightcontent/page.rb
brightcontent-2.0.0.alpha3 pages/app/models/brightcontent/page.rb
brightcontent-pages-2.0.0.alpha3 app/models/brightcontent/page.rb
brightcontent-2.0.0.alpha2 pages/app/models/brightcontent/page.rb
brightcontent-pages-0.0.1 app/models/brightcontent/page.rb