Defect #14298

Error generated on 'search for watchers to add' after clicking add without selected users

Added by Ricardo S over 4 years ago. Updated almost 4 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:Issues
Target version:2.5.1
Resolution:Fixed Affected version:

Description

On the New Issue page, after clicking Add on Search for watchers to add without selecting any user, generates the following error on the logs:

An ActionView::Template::Error occurred in watchers#append:

undefined method `each' for nil:NilClass
app/views/watchers/append.js.erb:1:in `_app_views_watchers_append_js_erb__1816769395046035616_62007020'
  actionpack (3.2.13) lib/action_view/template.rb:145:in `block in render'
  activesupport (3.2.13) lib/active_support/notifications.rb:125:in `instrument'
  actionpack (3.2.13) lib/action_view/template.rb:143:in `render'
  actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:47:in `block (2 levels) in render_template'
  actionpack (3.2.13) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
(...)

A possible fix is to change WatchersController#append to render nothing when no user is selected:

  def append
    if params[:watcher].is_a?(Hash)
      user_ids = params[:watcher][:user_ids] || [params[:watcher][:user_id]]
      @users = User.active.find_all_by_id(user_ids)
    else
      render :nothing => true
    end
  end

My redmine environment is:
---

Environment:
  Redmine version                          2.3.1.devel
  Ruby version                             1.9.3 (x86_64-linux)
  Rails version                            3.2.13
  Environment                              production
  Database adapter                         PostgreSQL
SCM:
  Subversion                               1.7.5
  Mercurial                                2.6.1
  Cvs                                      1.12.13
  Bazaar                                   2.6
  Git                                      1.7.10.4
  Filesystem                               


Related issues

Duplicated by Redmine - Defect #16379: Undefined method `each' for nil:NilClass on search for wa... Closed

Associated revisions

Revision 12985
Added by Jean-Philippe Lang almost 4 years ago

Fixed: Error generated on 'search for watchers to add' after clicking add without selected users (#14298).

History

#1 Updated by Jean-Philippe Lang almost 4 years ago

  • Status changed from New to Resolved
  • Assignee set to Jean-Philippe Lang
  • Target version set to 2.5.1
  • Resolution set to Fixed

Fixed in r12985.

#2 Updated by Jean-Philippe Lang almost 4 years ago

  • Duplicated by Defect #16379: Undefined method `each' for nil:NilClass on search for watchers to add added

#3 Updated by Jean-Philippe Lang almost 4 years ago

  • Status changed from Resolved to Closed

Merged.

Also available in: Atom PDF