如何解决气泡通过重定向通知
| 我的情况: 在控制器中,确认用户后,我重定向到root用户(登录页面:statics#landing
),并附上一条通知:
redirect_to root_url,notice: \'Confirmation successful.\'
但在那儿,我总是检查用户是否已经登录,如果是,我会将其重定向到实际索引:
def landing
redirect_to actual_index_url if (user.signed_in?)
end
如何将确认通知传播到最后一页?
解决方法
我想您正在寻找
flash.keep
。
http://railsapi.com/doc/rails-v3.0.8rc1/classes/ActionDispatch/Flash/FlashHash.html#M006014
, 尝试:
def landing
redirect_to actual_index_url,:notice => flash[:notice] if (user.signed_in?)
end
, flash.keep(:notice)
-如果您只想保留通知,flash.keep
将同时保留:notices
和:errors
。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。