ruby-on-rails – 带有redirect_to的Flash通知在rails中被破坏
发布时间:2020-12-16 23:14:42 所属栏目:百科 来源:网络整理
导读:我更新到Rails 2.3.10,Rack 1.2.1,现在我的flash消息都没有出现.我发现在重定向期间,通知会像这样传递 redirect_to(@user,:notice = "Sorry there was an error") 在我看来,flash哈希是空的 %= debug flash % !map:ActionController::Flash::FlashHash {} 但
我更新到Rails 2.3.10,Rack 1.2.1,现在我的flash消息都没有出现.我发现在重定向期间,通知会像这样传递
redirect_to(@user,:notice => "Sorry there was an error") 在我看来,flash哈希是空的 <%= debug flash %> !map:ActionController::Flash::FlashHash {} 但是您可以在控制器中看到该消息.是什么赋予了? <%= debug controller.session %> session{:home_zip=>"94108",:session_id=>"xxx",:flash=>{:notice=>"Sorry there was an error"},:user_credentials=>"1baf9c9c0423ce0151ec32e24cc422f07309e4ba503eb4830635ecc115da217809997324374bb273b3fb792895c9741a8b8c9ea4267771a1bd149de5b9179ea0",:user_credentials_id=>22,:home_market_id=>11} Edit Profile 解决方法
我们也碰到了这个.我们所有的Flash消息都会通过重定向消失,但不会在控制器中明确设置时消失.
不起作用: def create if @obj.save flash[:notice] = "The #{cname.humanize.downcase} has been created." redirect_back_or_default redirect_url else render :action => 'new' end end 这确实有效: def show @user = current_user flash[:notice] = "Hello -- this will show up fine" end (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |