From 1ae23bafe44ceb73253cea825c338c82f1b93d74 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Tue, 26 Jul 2016 10:12:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=9B=9E=E5=8E=9F=E6=9D=A5=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb b/lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb index 5fd428166..26c78cdd2 100644 --- a/lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb +++ b/lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb @@ -10,7 +10,7 @@ module Redmine def acts_as_watchable(options = {}) return if self.included_modules.include?(Redmine::Acts::Watchable::InstanceMethods) class_eval do - has_many :watchers, :dependent => :delete_all + has_many :watchers, :as => :watchable, :dependent => :delete_all has_many :watcher_users, :through => :watchers, :source => :user, :validate => false scope :watched_by, lambda { |user_id| @@ -51,7 +51,7 @@ module Redmine #通过model层删除以触发before_destroy事件 -by zjc watchers = Watcher.find_by_sql "select * from `watchers` where watchable_type = 'Principal' AND watchable_id = #{self.id} AND user_id = #{user.id}" watchers.each do |watcher| - watcher.destroy + watcher.destroy end #Watcher.delete_all "watchable_type = 'Principal' AND watchable_id = #{self.id} AND user_id = #{user.id}" else