Sha256: 9fe815a9f8c522323a614491a7d94b02c19a4bc6f2060fa6d49ac817191f0ff6

Contents?: true

Size: 733 Bytes

Versions: 2

Compression:

Stored size: 733 Bytes

Contents

class Ecm::CmsNavigation::Navigation < ActiveRecord::Base
  self.table_name = 'ecm_cms_navigation_navigations'

  has_many :navigation_items, :dependent => :destroy, :class_name => 'Ecm::CmsNavigation::NavigationItem'
  
  validates :name, :presence => true, :uniqueness => { :scope => :locale }, :format => { :with => /[a-z\-]{1,}/i }
  validates :locale,  :inclusion => I18n.available_locales.map(&:to_s), :unless => Proc.new { |navigation| navigation.locale.blank? }

  attr_accessible :locale, :name
  
  def to_s
    "#{self.locale}: #{self.name}"
  end  
  
  before_validation :downcase_name
  
  def downcase_name
    self.name.downcase!
  end  
  
  def has_navigation_items?
    self.navigation_items.count > 0
  end  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ecm_cms_navigation-0.0.5 app/models/ecm/cms_navigation/navigation.rb
ecm_cms_navigation-0.0.4 app/models/ecm/cms_navigation/navigation.rb