Fix for submenu automation
This commit is contained in:
parent
3cd3a8bd73
commit
aaf7f7362c
|
@ -23,7 +23,7 @@ class Item
|
|||
|
||||
before_destroy :destroy_children
|
||||
after_rearrange :rebuild_path, :if => "parent_id_changed? || name_changed?"
|
||||
after_save :rebuild_children_path, :rebuild_parent_path, :if => "path_changed?"
|
||||
after_save :rebuild_children_path, :rebuild_page_children_path, :if => "path_changed?"
|
||||
|
||||
def enabled_for_lang(lang)
|
||||
enabled_for.include?(lang) rescue false
|
||||
|
@ -92,9 +92,13 @@ class Item
|
|||
end
|
||||
end
|
||||
|
||||
def rebuild_parent_path
|
||||
parent = self.parent
|
||||
parent.descendants_and_self
|
||||
def rebuild_page_children_path
|
||||
page = Page.find(self.id)
|
||||
page.children.each do |child|
|
||||
child.path = (child.ancestors_and_self - [Page.root]).collect{|x| x.name}.join('/')
|
||||
child.save
|
||||
child.rebuild_children_path
|
||||
end
|
||||
end
|
||||
|
||||
# Enable the validation for parent_id
|
||||
|
|
Reference in New Issue