所有者的更新时间随着被拥有者的改变而改天

譬如course 里边这么写:has_many :boards
boards里边这么写就ok:belongs_to :course,:touch=>true
This commit is contained in:
lizanle 2015-11-30 12:55:19 +08:00
parent 62399b6d72
commit 96b704e191
5 changed files with 5 additions and 4 deletions

View File

@ -18,7 +18,7 @@
class Board < ActiveRecord::Base
include Redmine::SafeAttributes
belongs_to :project,:touch => true
belongs_to :course
belongs_to :course,:touch=>true
has_many :topics, :class_name => 'Message', :conditions => "#{Message.table_name}.parent_id IS NULL", :order => "#{Message.table_name}.created_on DESC"
has_many :messages, :dependent => :destroy, :order => "#{Message.table_name}.created_on DESC"
belongs_to :last_message, :class_name => 'Message', :foreign_key => :last_message_id

View File

@ -31,7 +31,7 @@ class Comment < ActiveRecord::Base
:title=>Proc.new {|o| "RE: #{o.commented.title}" },
:url => Proc.new {|o| {:controller => 'news', :action => 'show', :id => o.commented.id} }
belongs_to :commented, :polymorphic => true, :counter_cache => true
belongs_to :commented, :polymorphic => true, :counter_cache => true,:touch => true
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
validates_presence_of :commented, :author, :comments
safe_attributes 'comments'

View File

@ -2,6 +2,7 @@ class Exercise < ActiveRecord::Base
#exercise_status: 1,新建2发布3关闭
include Redmine::SafeAttributes
belongs_to :user
belongs_to :course ,:touch => true
has_many :exercise_questions, :dependent => :destroy,:order => "#{ExerciseQuestion.table_name}.question_number"
has_many :exercise_users, :dependent => :destroy
has_many :users, :through => :exercise_users #该测试被哪些用户提交答案过

View File

@ -24,7 +24,7 @@ class JournalsForMessage < ActiveRecord::Base
:conditions => "#{self.table_name}.jour_type = 'Project' ",:touch => true
belongs_to :course,
:foreign_key => 'jour_id'
:foreign_key => 'jour_id',:touch=>true
belongs_to :jour, :polymorphic => true

View File

@ -21,7 +21,7 @@ class News < ActiveRecord::Base
include ApplicationHelper
has_many_kindeditor_assets :assets, :dependent => :destroy
#added by nwb
belongs_to :course
belongs_to :course,:touch => true
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
has_many :comments, :as => :commented, :dependent => :destroy, :order => "created_on"
# fq