]> source.dussan.org Git - redmine.git/commitdiff
Rescue and display an error message when trying to delete a role that is in use.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 16 Feb 2008 21:05:10 +0000 (21:05 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 16 Feb 2008 21:05:10 +0000 (21:05 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1159 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/roles_controller.rb

index a8a31cd4d263c8aef04206dda6798f87184849bc..4796bb7f05c78c52e20a1becd59f21e311cb82e8 100644 (file)
@@ -53,12 +53,11 @@ class RolesController < ApplicationController
 
   def destroy
     @role = Role.find(params[:id])
-    #unless @role.members.empty?
-    #  flash[:error] = 'Some members have this role. Can\'t delete it.'
-    #else
-      @role.destroy
-    #end
+    @role.destroy
     redirect_to :action => 'list'
+  rescue
+    flash[:error] = 'This role is in use and can not be deleted.'
+    redirect_to :action => 'index'
   end
   
   def move