兼容ruby2.3.1

This commit is contained in:
guange 2016-07-21 17:21:02 +08:00
parent 674c45f1d9
commit 080b2ac2fa
1 changed files with 5 additions and 1 deletions

View File

@ -10,7 +10,11 @@ module Redmine
def acts_as_watchable(options = {})
return if self.included_modules.include?(Redmine::Acts::Watchable::InstanceMethods)
class_eval do
has_many :watchers, :as => :watchable, :dependent => :delete_all
if self.name == 'User'
has_many :watchers, :dependent => :delete_all
else
has_many :watchers, :as => :watchable, :dependent => :delete_all
end
has_many :watcher_users, :through => :watchers, :source => :user, :validate => false
scope :watched_by, lambda { |user_id|