Sha256: df314c5e6314d977919e73a286d905bba2c48a17eacda5de14393e2cc9055333
Contents?: true
Size: 1.47 KB
Versions: 2
Compression:
Stored size: 1.47 KB
Contents
class Ecm::Downloads::DownloadCategory < ActiveRecord::Base # db settings self.table_name = 'ecm_downloads_download_categories' # associations has_many :ecm_downloads_downloads, -> { order(:position) }, class_name: Ecm::Downloads::Download, dependent: :destroy, foreign_key: :ecm_downloads_download_category_id, inverse_of: :ecm_downloads_download_category accepts_nested_attributes_for :ecm_downloads_downloads, allow_destroy: true # attributes attr_accessible :description, :ecm_downloads_downloads_attributes, :ecm_downloads_downloads_count, :locale, :name, :parent_id, :position, :slug if respond_to? :attr_accessible # awesome nested set acts_as_nested_set default_scope { order('lft ASC') } # friendly id extend FriendlyId friendly_id :name, use: [:slugged] # validations validates :name, presence: true, uniqueness: { scope: [:parent_id] } validates :locale, presence: true, if: :root? validates :locale, inclusion: I18n.available_locales.map(&:to_s), if: proc { |cc| cc.locale.present? } validates :locale, absence: true, unless: :root? def ecm_downloads_downloads_count ecm_downloads_downloads.count end def human name end def to_s name end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ecm_downloads2-3.0.0 | app/models/ecm/downloads/download_category.rb |
ecm_downloads2-2.0.3 | app/models/ecm/downloads/download_category.rb |