| |

VerySource

 Forgot password?
 Register
Search
View: 1235|Reply: 5

type of ruby ​​rails session variable

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 United States

Post time: 2020-1-30 16:20:01
| Show all posts |Read mode
The code for calling session in the rails controller is as follows:
session [: cart}] ...
Why is there no @ sign in front of the session.
Similarly, flash and logger have the same problem. Are they local, instance or constant variables?
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-3-13 10:15:01
| Show all posts
Here session is a HASH type object, cart is a key, and session [: cart] is corresponding to this key
value
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-4-18 11:45:01
| Show all posts
Why is there no @ sign in front of the session, no @ sign, so it becomes a local variable? Can't it be referenced by other methods?
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-4-19 20:15:01
| Show all posts
The session does not appear to be a variable, but the message name.
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-7-13 20:00:01
| Show all posts
session is actually method
Of course you can use @session, but this is not recommended
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-1 04:00:01
| Show all posts
Also not recommended is @params, you can check the documentation for details. In addition, to remind the host, session['user'] and session[:user] will return two different references...
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list