class Board < ActiveRecord::Base
include Redmine::SafeAttributes
belongs_to :project
- has_many :topics, lambda {where("#{Message.table_name}.parent_id IS NULL").order("#{Message.table_name}.created_on DESC")}, :class_name => 'Message'
has_many :messages, lambda {order("#{Message.table_name}.created_on DESC")}, :dependent => :destroy
belongs_to :last_message, :class_name => 'Message'
acts_as_tree :dependent => :nullify
name
end
+ # Returns a scope for the board topics (messages without parent)
+ def topics
+ messages.where(:parent_id => nil)
+ end
+
def valid_parents
@valid_parents ||= project.boards - self_and_descendants
end