Sha256: 11459e20349fa9ae2524ae58d7eb4ea57bcf529d1a2560856ebd41f0d3455326
Contents?: true
Size: 1017 Bytes
Versions: 3
Compression:
Stored size: 1017 Bytes
Contents
class Ecm::CmsNavigation::NavigationItem < ActiveRecord::Base self.table_name = 'ecm_cms_navigation_navigation_items' belongs_to :navigation, :class_name => 'Ecm::CmsNavigation::Navigation' acts_as_nested_set :dependent => :destroy, :counter_cache => :children_count, :scope => :navigation_id attr_protected :lft, :rgt validates :name, :presence => true validates :url, :presence => true validates :key, :presence => true default_scope :order => [:navigation_id, :lft] def to_s self.name end def indented_name "#{'    ' * self.level} |--#{self.name}".html_safe end before_validation :set_navigation, :if => Proc.new { |navigation_item| navigation_item.child? } after_save :update_children_navigations! def set_navigation self.navigation = self.parent.navigation end def set_navigation! self.set_navigation self.save! end def update_children_navigations! self.children.map(&:"set_navigation!") end end
Version data entries
3 entries across 3 versions & 1 rubygems