Updated Items

This commit is contained in:
saurabhbhatia 2014-01-07 15:51:07 +08:00
parent 1a90990311
commit 3938f7df06
1 changed files with 6 additions and 1 deletions

View File

@ -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, :if => "path_changed?"
after_save :rebuild_children_path, :rebuild_parent_path, :if => "path_changed?"
def enabled_for_lang(lang)
enabled_for.include?(lang) rescue false
@ -92,6 +92,11 @@ class Item
end
end
def rebuild_parent_path
parent = self.parent
parent.descendants_and_self
end
# Enable the validation for parent_id
def validates_presence_of_parent_id?
true