改回原来的
This commit is contained in:
parent
e6e8d73a66
commit
1ae23bafe4
|
@ -10,7 +10,7 @@ module Redmine
|
||||||
def acts_as_watchable(options = {})
|
def acts_as_watchable(options = {})
|
||||||
return if self.included_modules.include?(Redmine::Acts::Watchable::InstanceMethods)
|
return if self.included_modules.include?(Redmine::Acts::Watchable::InstanceMethods)
|
||||||
class_eval do
|
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
|
has_many :watcher_users, :through => :watchers, :source => :user, :validate => false
|
||||||
|
|
||||||
scope :watched_by, lambda { |user_id|
|
scope :watched_by, lambda { |user_id|
|
||||||
|
@ -51,7 +51,7 @@ module Redmine
|
||||||
#通过model层删除以触发before_destroy事件 -by zjc
|
#通过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 = 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|
|
watchers.each do |watcher|
|
||||||
watcher.destroy
|
watcher.destroy
|
||||||
end
|
end
|
||||||
#Watcher.delete_all "watchable_type = 'Principal' AND watchable_id = #{self.id} AND user_id = #{user.id}"
|
#Watcher.delete_all "watchable_type = 'Principal' AND watchable_id = #{self.id} AND user_id = #{user.id}"
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue