Sha256: 70032b091fa29ae3c19f7b27aefb502714f0e44af5d24d89ab387f56b2558225

Contents?: true

Size: 595 Bytes

Versions: 15

Compression:

Stored size: 595 Bytes

Contents

class MenuItem < ActiveRecord::Base

  belongs_to :parent, :class_name=>"MenuItem"
  has_many :children, :foreign_key=>"parent_id", :class_name=>"MenuItem", :order=>:order_by
  belongs_to :menu
  validates :name, :length=>{:minimum=>1, :maximum=>200}
  validates :link_url, :length=>{:minimum=>1, :maximum=>200}
  after_save :flush_parent_menu_cache

  def flush_parent_menu_cache
    self.menu.flush
  end


  def child_is_current(url)
    self.children.each do |child|
      return true if child.link_url==url
    end

    return false
  end

  def has_children?
    children.size>0
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
kit_cms-2.3.22 app/models/menu_item.rb
kit_cms-2.3.20 app/models/menu_item.rb
kit_cms-2.3.19 app/models/menu_item.rb
kit_cms-2.3.18 app/models/menu_item.rb
kit_cms-2.3.17 app/models/menu_item.rb
kit_cms-2.3.16 app/models/menu_item.rb
kit_cms-2.3.15 app/models/menu_item.rb
kit_cms-2.3.14 app/models/menu_item.rb
kit_cms-2.3.13 app/models/menu_item.rb
kit_cms-2.3.11 app/models/menu_item.rb
kit_cms-2.3.10 app/models/menu_item.rb
kit_cms-2.3.9 app/models/menu_item.rb
kit_cms-2.3.8 app/models/menu_item.rb
kit_cms-2.3.7 app/models/menu_item.rb
kit_cms-2.3.6 app/models/menu_item.rb