Sha256: 72717d7501cbce2a06875650313f77d31c78f3a960e5dc18de502bb1b8c64837

Contents?: true

Size: 915 Bytes

Versions: 3

Compression:

Stored size: 915 Bytes

Contents

class Forum < ActiveRecord::Base
  acts_as_list

  validates_presence_of :name

  has_many :topics, :order => 'sticky desc, replied_at desc', :dependent => :delete_all
  has_one  :recent_topic, :class_name => 'Topic', :order => 'sticky desc, replied_at desc'

  # this is used to see if a forum is "fresh"... we can't use topics because it puts
  # stickies first even if they are not the most recently modified
  has_many :recent_topics, :class_name => 'Topic', :order => 'replied_at DESC'
  has_one  :recent_topic,  :class_name => 'Topic', :order => 'replied_at DESC'

  has_many :posts,     :order => "#{Post.table_name}.created_at DESC", :dependent => :delete_all
  has_one  :recent_post, :order => "#{Post.table_name}.created_at DESC", :class_name => 'Post'

  format_attribute :description
  
  # retrieves forums ordered by position
  def self.find_ordered(options = {})
    self.order('position')
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tamed_beast-0.0.3 app/models/forum.rb
tamed_beast-0.0.2 app/models/forum.rb
tamed_beast-0.0.1 app/models/forum.rb