Sha256: ade69764f99879c7efc6593b995ca46d2e3c720b07858cbd986ac3e36dee8863
Contents?: true
Size: 1.22 KB
Versions: 2
Compression:
Stored size: 1.22 KB
Contents
class Ecm::CmsNavigation::NavigationItem < ActiveRecord::Base # database sesttings self.table_name = 'ecm_cms_navigation_navigation_items' # associations belongs_to :navigation, :class_name => Ecm::CmsNavigation::Navigation # attributes attr_protected :lft, :rgt # awesome nested set acts_as_nested_set :dependent => :destroy, :counter_cache => :children_count, :scope => :navigation_id # callbacks before_validation :set_navigation, :if => Proc.new { |navigation_item| navigation_item.child? } after_save :update_children_navigations! # default_scope default_scope :order => [:navigation_id, :lft] # # friendly id # extend FriendlyId # friendly_id :name, :use => :slugged # validations validates :name, :presence => true validates :url, :presence => true validates :key, :presence => true # public methods def indented_name "#{'    ' * self.level} |--#{self.name}".html_safe end def set_navigation self.navigation = self.parent.navigation end def set_navigation! self.set_navigation self.save! end def to_s self.name end def update_children_navigations! self.children.map(&:"set_navigation!") end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ecm_cms_navigation-0.0.13 | app/models/ecm/cms_navigation/navigation_item.rb |
ecm_cms_navigation-0.0.12 | app/models/ecm/cms_navigation/navigation_item.rb |