Ruby on rails - 闪存变量 [英] Ruby on rails - flash variable

查看:38
本文介绍了Ruby on rails - 闪存变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Rails 完全陌生.在学习期间,我遇到了使用 flash 变量在重定向时为下一次回发维护数据的情况.

I'm completely new to rails. While learning I came across the use of the flash variable for maintaining data for the next postback when redirecting.

我的问题是

  1. 什么时候使用.

  1. when should this be used.

rails 如何为我维护它,它是往返于用户并返回还是在服务器端维护.

how does rails maintain it for me, does it make a round trip to the user and back or is it maintained server side.

任何回复将不胜感激

推荐答案

flash 用于存储下一次请求所需的数据(一般为文本),并在下一次请求后自动删除.

flash is used to store the data (generally text) which required in next request and it get deleted automatically after the next request.

flash 只不过是一个存储在会话中并由 rails 本身(服务器端)维护的对象.

flash is nothing but an object which stores in session and maintain by rails itself (server side).

Rails 初始化 flash 对象,并在下一个请求中将其标记为删除,以便在下一个请求中将其删除.

Rails initialize the flash object and marked it for removal in next request so it gets deleted in next request.

这篇关于Ruby on rails - 闪存变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆