OSDN Git Service

Redirects back after clicking watch/unwatch links without javascript (#1337).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 29 Jun 2008 19:56:20 +0000 (19:56 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 29 Jun 2008 19:56:20 +0000 (19:56 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1607 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/watchers_controller.rb

index 206dc08..014779b 100644 (file)
@@ -23,18 +23,22 @@ class WatchersController < ApplicationController
     user = User.current
     @watched.add_watcher(user)
     respond_to do |format|
-      format.html { render :text => 'Watcher added.', :layout => true }
+      format.html { redirect_to :back }
       format.js { render(:update) {|page| page.replace_html 'watcher', watcher_link(@watched, user)} }
     end
+  rescue RedirectBackError
+    render :text => 'Watcher added.', :layout => true
   end
   
   def remove
     user = User.current
     @watched.remove_watcher(user)
     respond_to do |format|
-      format.html { render :text => 'Watcher removed.', :layout => true }
+      format.html { redirect_to :back }
       format.js { render(:update) {|page| page.replace_html 'watcher', watcher_link(@watched, user)} }
     end
+  rescue RedirectBackError
+    render :text => 'Watcher removed.', :layout => true
   end
 
 private