Override watcher_user_ids= in acts_as_watchable to make user_ids uniq

pull/1186/head
Philipp Tessenow 12 years ago
parent 64418fc8fd
commit 46274632f5
  1. 8
      lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb

@ -55,6 +55,14 @@ module Redmine
watching ? add_watcher(user) : remove_watcher(user)
end
# Overrides watcher_user_ids= to make user_ids uniq
def watcher_user_ids_with_uniq_ids=(user_ids)
if user_ids.is_a?(Array)
user_ids = user_ids.uniq
end
send :watcher_user_ids_without_uniq_ids=, user_ids
end
# Returns true if object is watched by +user+
def watched_by?(user)
!!(user && self.watcher_user_ids.detect {|uid| uid == user.id })

Loading…
Cancel
Save