From: Jean-Philippe Lang Date: Wed, 2 Dec 2009 19:17:42 +0000 (+0000) Subject: Make use of #watched_by? in issue form. X-Git-Tag: 0.9.0~148 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e5dc94fe82cba5a8f099f8512e95144fa3a6aca1;p=redmine.git Make use of #watched_by? in issue form. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3114 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/views/issues/_form.rhtml b/app/views/issues/_form.rhtml index 5337b51be..032d08205 100644 --- a/app/views/issues/_form.rhtml +++ b/app/views/issues/_form.rhtml @@ -23,7 +23,7 @@ <% if @issue.new_record? && User.current.allowed_to?(:add_issue_watchers, @project) -%>

<% @issue.project.users.sort.each do |user| -%> - + <% end -%>

<% end %> diff --git a/vendor/plugins/acts_as_watchable/lib/acts_as_watchable.rb b/vendor/plugins/acts_as_watchable/lib/acts_as_watchable.rb index 3d0de0dca..977ab4fc7 100644 --- a/vendor/plugins/acts_as_watchable/lib/acts_as_watchable.rb +++ b/vendor/plugins/acts_as_watchable/lib/acts_as_watchable.rb @@ -46,10 +46,9 @@ module Redmine watching ? add_watcher(user) : remove_watcher(user) end - # Returns if object is watched by user + # Returns true if object is watched by user def watched_by?(user) - !self.watchers.find(:first, - :conditions => ["#{Watcher.table_name}.user_id = ?", user.id]).nil? + !!(user && self.watchers.detect {|w| w.user_id == user.id }) end # Returns an array of watchers' email addresses