Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
为当前视图设置闪存消息但不为下一个请求显示它的正确方法是什么。换句话说,通常您设置 Flash 消息和重定向,并且 Flash 消息会显示在重定向上。我不想重定向,所以我需要确保 Flash 消息不会显示两次。
flash.now[:notice] = 'message'
如果要“渲染”页面,请使用flash.now[:notice],当您要“重定向”时,请使用flash[:notice]
flash.now[:notice]
flash[:notice]