2010-05-20 66 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插件。更新插件分支版本工作,雖然我打算完全擺脫它。

相關問題