Fixed error message display in admin/edit_web - Rails flash handling apparently has changed

This commit is contained in:
Alexey Verkhovsky 2005-05-09 03:41:00 +00:00
parent f1c5004543
commit b3e355f4bc
4 changed files with 12 additions and 10 deletions

View file

@ -36,7 +36,7 @@ class AdminController < ApplicationController
redirect_to :web => @params['address'], :controller => 'wiki', :action => 'new', redirect_to :web => @params['address'], :controller => 'wiki', :action => 'new',
:id => 'HomePage' :id => 'HomePage'
rescue Instiki::ValidationError => e rescue Instiki::ValidationError => e
flash[:error] = e.message @error = e.message
# and re-render the form again # and re-render the form again
end end
else else
@ -48,6 +48,7 @@ class AdminController < ApplicationController
end end
def edit_web def edit_web
system_password = @params['system_password'] system_password = @params['system_password']
if system_password if system_password
# form submitted # form submitted
@ -68,11 +69,11 @@ class AdminController < ApplicationController
flash[:info] = "Web '#{@params['address']}' was successfully updated" flash[:info] = "Web '#{@params['address']}' was successfully updated"
redirect_home(@params['address']) redirect_home(@params['address'])
rescue Instiki::ValidationError => e rescue Instiki::ValidationError => e
flash[:error] = e.message @error = e.message
# and re-render the same template again # and re-render the same template again
end end
else else
flash[:error] = password_error(system_password) @error = password_error(system_password)
# and re-render the same template again # and re-render the same template again
end end
else else

View file

@ -36,8 +36,8 @@ class FileController < ApplicationController
if @params['file'] if @params['file']
# form supplied # form supplied
file_yard.upload_file(@file_name, @params['file']) file_yard.upload_file(@file_name, @params['file'])
flash[:info] = "Image '#{@file_name}' successfully uploaded"
@web.refresh_pages_with_references(@file_name) @web.refresh_pages_with_references(@file_name)
flash[:info] = "Image '#{@file_name}' successfully uploaded"
return_to_last_remembered return_to_last_remembered
elsif file_yard.has_file?(@file_name) elsif file_yard.has_file?(@file_name)
send_file(file_yard.file_path(@file_name)) send_file(file_yard.file_path(@file_name))
@ -59,7 +59,7 @@ class FileController < ApplicationController
if @problems.empty? if @problems.empty?
flash[:info] = 'Import successfully finished' flash[:info] = 'Import successfully finished'
else else
flash[:info] = "Import finished, but some pages were not imported:<li>" + flash[:error] = "Import finished, but some pages were not imported:<li>" +
@problems.join('</li><li>') + '</li>' @problems.join('</li><li>') + '</li>'
end end
return_to_last_remembered return_to_last_remembered

View file

@ -46,6 +46,7 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
</head> </head>
<body> <body>
<div id="Container"> <div id="Container">
<div id="Content"> <div id="Content">
<h1 id="pageName"> <h1 id="pageName">
@ -59,8 +60,8 @@ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<% end %> <% end %>
</h1> </h1>
<% if @flash[:error] %> <div id="error"> <% if @error or @flash[:error] %> <div id="error">
<hr/><p><%= @flash[:error].to_s %></p><hr/></div> <hr/><p><%= (@error || @flash[:error]) %></p><hr/></div>
<% end %> <% end %>
<% if @flash[:info] %> <div id="info"> <% if @flash[:info] %> <div id="info">

View file

@ -155,7 +155,7 @@ class AdminControllerTest < Test::Unit::TestCase
#returns to the same form #returns to the same form
assert_success assert_success
assert_flash_has :error assert @response.has_template_object?(:error)
end end
def test_edit_web_rename_to_already_existing_web_name def test_edit_web_rename_to_already_existing_web_name
@ -169,7 +169,7 @@ class AdminControllerTest < Test::Unit::TestCase
#returns to the same form #returns to the same form
assert_success assert_success
assert_flash_has :error assert @response.has_template_object?(:error)
end end
def test_edit_web_empty_password def test_edit_web_empty_password
@ -180,7 +180,7 @@ class AdminControllerTest < Test::Unit::TestCase
#returns to the same form #returns to the same form
assert_success assert_success
assert_flash_has :error assert @response.has_template_object?(:error)
end end