From 5336205c79c811a00168d30a011382502f938017 Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Fri, 6 Nov 2020 13:00:05 +0000 Subject: [PATCH] shorten long line of WatchersController git-svn-id: http://svn.redmine.org/redmine/trunk@20272 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/watchers_controller.rb | 27 +++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/app/controllers/watchers_controller.rb b/app/controllers/watchers_controller.rb index 645e60fe2..f4e8f2287 100644 --- a/app/controllers/watchers_controller.rb +++ b/app/controllers/watchers_controller.rb @@ -50,9 +50,13 @@ class WatchersController < ApplicationController end end respond_to do |format| - format.html { redirect_to_referer_or {render :html => 'Watcher added.', :status => 200, :layout => true}} - format.js { @users = users_for_new_watcher } - format.api { render_api_ok } + format.html do + redirect_to_referer_or do + render(:html => 'Watcher added.', :status => 200, :layout => true) + end + end + format.js {@users = users_for_new_watcher} + format.api {render_api_ok} end end @@ -72,9 +76,13 @@ class WatchersController < ApplicationController watchable.set_watcher(user, false) end respond_to do |format| - format.html { redirect_to_referer_or {render :html => 'Watcher removed.', :status => 200, :layout => true} } + format.html do + redirect_to_referer_or do + render(:html => 'Watcher removed.', :status => 200, :layout => true) + end + end format.js - format.api { render_api_ok } + format.api {render_api_ok} end rescue ActiveRecord::RecordNotFound render_404 @@ -113,9 +121,14 @@ class WatchersController < ApplicationController respond_to do |format| format.html do text = watching ? 'Watcher added.' : 'Watcher removed.' - redirect_to_referer_or {render :html => text, :status => 200, :layout => true} + redirect_to_referer_or do + render(:html => text, :status => 200, :layout => true) + end + end + format.js do + render(:partial => 'set_watcher', + :locals => {:user => user, :watched => watchables}) end - format.js { render :partial => 'set_watcher', :locals => {:user => user, :watched => watchables} } end end -- 2.39.5