Sha256: 6ea39431d5f709f823fa35b3729ac2a1af84dd12233138ab7026aacdd1e38645

Contents?: true

Size: 757 Bytes

Versions: 1

Compression:

Stored size: 757 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! unless self.name.blank?
  end  
  
  def has_navigation_items?
    self.navigation_items.count > 0
  end  
end

Version data entries

1 entries across 1 versions & 1 rubygems

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