컨트롤러에서 예외 처리를 수행하고 있습니다. : create 작업에서 예외가 발생하면 : new 작업으로 렌더링하고 플래시 메시지를 표시합니다.
모든 것이 잘 작동하고 예외가 발생하면 플래시 메시지를 볼 수 있지만 다른 페이지로 리디렉션 (손으로 클릭) 하면 플래시 메시지가 여전히 여기에 있습니다 . 그런 다음 다른 페이지 ( 두 번째 클릭)로 리디렉션 하면 메시지가 사라질 수 있습니다.
이유가 무엇인지 아는 사람?
내 컨트롤러 코드 :
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]