How does "flash" in Rails make a global application?

I'm curious how Rails accomplishes this. I notice that you can access the variable flashglobally in the application, but it does not have a prefix with @or $.

I also see that there is a way to access as flashwell as an initializer that will install @flash, but how can I call flashas a local variable?

+4
source share
1 answer

Session

Besides the answer apneadiving, it flashis part of the middleware stack ( ActionDispatch::Flash). This is actually a fickle cookie session:

-

:

- , . , , ..

, params ( ), flash .

-

Middleware

apneadiving, , flash middleware - , ( , params), / flash , " " - ,

, - apneadiving , ,

+5

Source: https://habr.com/ru/post/1543940/


All Articles