##// END OF EJS Templates
Fixed: unable to migrate from an empty database....
Jean-Philippe Lang -
r760:66c8c1e29249
parent child
Show More
@@ -1,46 +1,49
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 class Message < ActiveRecord::Base
19 19 belongs_to :board
20 20 belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
21 21 acts_as_tree :counter_cache => :replies_count, :order => "#{Message.table_name}.created_on ASC"
22 22 has_many :attachments, :as => :container, :dependent => :destroy
23 23 belongs_to :last_reply, :class_name => 'Message', :foreign_key => 'last_reply_id'
24 24
25 acts_as_searchable :columns => ['subject', 'content'], :include => :board, :project_key => "project_id"
25 acts_as_searchable :columns => ['subject', 'content'],
26 :include => :board,
27 :project_key => 'project_id',
28 :date_column => 'created_on'
26 29 acts_as_event :title => Proc.new {|o| "#{o.board.name}: #{o.subject}"},
27 30 :description => :content,
28 31 :url => Proc.new {|o| {:controller => 'messages', :action => 'show', :board_id => o.board_id, :id => o.id}}
29 32
30 33 validates_presence_of :subject, :content
31 34 validates_length_of :subject, :maximum => 255
32 35
33 36 def after_create
34 37 board.update_attribute(:last_message_id, self.id)
35 38 board.increment! :messages_count
36 39 if parent
37 40 parent.reload.update_attribute(:last_reply_id, self.id)
38 41 else
39 42 board.increment! :topics_count
40 43 end
41 44 end
42 45
43 46 def project
44 47 board.project
45 48 end
46 49 end
General Comments 0
You need to be logged in to leave comments. Login now