Avoid setting page as parent id, which has current page as parent.
This commit is contained in:
parent
20b7db306b
commit
6c82d0e06a
3 changed files with 14 additions and 6 deletions
|
@ -14,10 +14,10 @@ GEM
|
||||||
haml (3.0.25)
|
haml (3.0.25)
|
||||||
mysql (2.8.1)
|
mysql (2.8.1)
|
||||||
prawn (0.6.3)
|
prawn (0.6.3)
|
||||||
prawn-core (>= 0.6.3, < 0.7)
|
prawn-core (< 0.7, >= 0.6.3)
|
||||||
prawn-format (>= 0.2.3, < 0.3)
|
prawn-format (< 0.3, >= 0.2.3)
|
||||||
prawn-layout (>= 0.3.2, < 0.4)
|
prawn-layout (< 0.4, >= 0.3.2)
|
||||||
prawn-security (>= 0.1.1, < 0.2)
|
prawn-security (< 0.2, >= 0.1.1)
|
||||||
prawn-core (0.6.3)
|
prawn-core (0.6.3)
|
||||||
prawn-format (0.2.3)
|
prawn-format (0.2.3)
|
||||||
prawn-core
|
prawn-core
|
||||||
|
|
|
@ -50,6 +50,10 @@ module PagesHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def parent_pages_to_select(current_page)
|
def parent_pages_to_select(current_page)
|
||||||
Page.non_redirected.reject { |p| p == current_page }
|
unless current_page.homepage? # Homepage is the page trees root!
|
||||||
|
Page.non_redirected.reject { |p| p == current_page or p.ancestors.include?(current_page) }
|
||||||
|
else
|
||||||
|
Array.new
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -37,6 +37,10 @@ class Page < ActiveRecord::Base
|
||||||
title.gsub(/[\/\.,;@\s]/, "_").gsub(/[\"\']/, "")
|
title.gsub(/[\/\.,;@\s]/, "_").gsub(/[\"\']/, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def homepage?
|
||||||
|
permalink == "Home"
|
||||||
|
end
|
||||||
|
|
||||||
def set_permalink
|
def set_permalink
|
||||||
unless title.blank?
|
unless title.blank?
|
||||||
self.permalink = Page.count == 0 ? "Home" : Page.permalink(title)
|
self.permalink = Page.count == 0 ? "Home" : Page.permalink(title)
|
||||||
|
|
Loading…
Reference in a new issue