【发布时间】:2011-06-04 13:52:43
【问题描述】:
我正在我的控制器中进行一些异常处理,当 :create 动作中抛出异常时,我将渲染到 :new 动作并显示一个 flash 消息。
一切正常,捕获异常时我可以看到闪烁消息,但是当我重定向到(手动单击)其他页面时,闪烁消息还在此处。然后我重定向到另一个页面(第二次点击),消息可能会消失。
谁知道是什么原因?
我的控制器代码:
class MessagesController < ApplicationController
rescue_from Exception, :with => :render_new
def new
end
def create
end
private
def render_new
flash[:alert] = t("uploading_error")
render :action => :new
end
end
我的布局代码(Haml):
%body
#content
- unless flash[:alert].blank?
#alert= flash[:alert]
【问题讨论】:
标签: ruby-on-rails