Sha256: 3adb4939798a32980769c975ca06b67b850ac850c60cf3182770c37306b5b54c

Contents?: true

Size: 510 Bytes

Versions: 3

Compression:

Stored size: 510 Bytes

Contents

module Kinney
  class Topic < ActiveRecord::Base
    attr_accessible :name, :description
    
    has_many :clip_topics
    has_many :clips, :through => :clip_topics
    
    extend FriendlyId
    friendly_id :name, :use => [:slugged, :history]
    
    validates :name, :description, :presence => true
    validates_uniqueness_of :name
    
    default_scope order('name ASC')
    
    def self.with_clips
      joins(:clips).group("kinney_topics.id HAVING count(kinney_clips.id) > 0")
    end
    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kinney-0.0.3 app/models/kinney/topic.rb
kinney-0.0.2 app/models/kinney/topic.rb
kinney-0.0.1 app/models/kinney/topic.rb