2010-05-20 64 views
1

这里我有两种控制器方法:Rails 2.3.5:flash [:notice]在redirect_to调用后消失

 def invite 
    if request.post? 
     begin 
     email = AccountMailer.create_invite(@user,url) 
     AccountMailer.deliver(email) 
     flash[:notice] = "Invitation email sent to #{@user.email}" 
     rescue 
     #mail delivery failed 
     flash[:error] = "Failed to deliver invitation" 
     end 

     redirect_to :action => :show, :id => @user.id 
    end 
    end 

 def show 
    @title = "User #{@user.full_name}" 
    end 

问题是,当我发送邀请并被重定向到./show时,我看不到任何消息。如果我将redirect_to更改为render,则会显示该消息。不过,闪存是否打算在随后的请求中工作?

BTW,我正在使用Rails + Passenger设置,是否可以将重定向的请求转到另一个应用程序实例?

回答

1

救援模块正在设置闪光[:错误],而不是闪光[:通知]。你的观点实际上是同时呈现吗?

+0

当然是。 – xyzman 2010-05-20 07:39:48

+0

事实上,我认为,如果在flash [:notice]之前发生救援,那么它将永远不会显示。 – Kezzer 2010-05-20 07:40:32

1

Google搜索更好的,发现这个讨论:

http://www.mail-archive.com/[email protected]/msg04284.html

的解决方案是存在的:替换

script/plugin install git://github.com/ewildgoose/render_component.git -r rails-2.3 --force 

插件虽然我不使用ActiveScaffold,有一些遗留代码取决于render_component插件。更新插件分支版本工作,虽然我打算完全摆脱它。