From 94a491e0ca98246be250fb2a3df4b2f3af39d925 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Wed, 22 Oct 2014 19:40:55 +0000 Subject: [PATCH] Replaced Board#topics with a regular method. git-svn-id: http://svn.redmine.org/redmine/trunk@13491 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/board.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/board.rb b/app/models/board.rb index 9777771a5..7e2507d8b 100644 --- a/app/models/board.rb +++ b/app/models/board.rb @@ -18,7 +18,6 @@ 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 @@ -52,6 +51,11 @@ class Board < ActiveRecord::Base 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 -- 2.39.5