]> source.dussan.org Git - redmine.git/commitdiff
Replaced Board#topics with a regular method.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 22 Oct 2014 19:40:55 +0000 (19:40 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 22 Oct 2014 19:40:55 +0000 (19:40 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@13491 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/board.rb

index 9777771a5eb4735806994dad2a0f6d7548707bae..7e2507d8bdf9f6246210666ec27f1720a5033a8c 100644 (file)
@@ -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