Fix destroy in structure

Fix sorting
This commit is contained in:
Christophe Vilayphiou committed 2012-05-22 17:55:45 +08:00
1 parent 541aa5831e
commit 11a371cbb9
2 files changed
+12 -6

No files matched your search

+4 -2
View File
@@ -10,16 +10,18 @@ class Item
field :is_published, :type => Boolean, :default => false
field :enabled_for, :type => Array, :default => nil
field :menu_enabled_for, :type => Array, :default => nil
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
validates_format_of :name, :with => /^[0-9a-zA-Z\-_]+$/
validates :name, :exclusion => { :in => LIST[:forbidden_item_names] }
validates_uniqueness_of :name, :scope => :parent_id
validates_presence_of :name
validates_associated :parent, :children
before_destroy :destroy_children
after_rearrange :rebuild_path
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
def self.find_by_name(item_name)
Item.first(:conditions => { :name => item_name, :is_published => true })