From b333e0797c4daf81232230e6a364a7f8b5b3491a Mon Sep 17 00:00:00 2001 From: Alexey Verkhovsky Date: Sat, 26 Mar 2005 00:09:41 +0000 Subject: [PATCH] More user-friendly error handling in admin/create_web --- app/controllers/admin_controller.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 9fcc0111..549356a6 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -19,7 +19,7 @@ class AdminController < ApplicationController Your new wiki '#{@params['web_name']}' is created!
Please edit its home page and press Submit when finished. EOL - redirect_to :web => @params['web_address'], :controller => 'wiki', :action => 'new', + redirect_to :web => @params['web_address'], :controller => 'wiki', :action => 'new', :id => 'HomePage' else # no form submitted -> go to template @@ -30,8 +30,14 @@ class AdminController < ApplicationController if @params['address'] # form submitted if @wiki.authenticate(@params['system_password']) - @wiki.create_web(@params['name'], @params['address']) - redirect_show('HomePage', @params['address']) + begin + @wiki.create_web(@params['name'], @params['address']) + flash[:info] = "New web '#{@params['name']}' successfully created." + redirect_to :web => @params['address'], :controller => 'wiki', :action => 'new', + :id => 'HomePage' + rescue Instiki::ValidationError => e + flash[:error] = e.message + end else redirect_to :controller => 'wiki', :action => 'index' end