I'm trying to figure out how to handle a user selecting a 'global' variable.
Specifically, I want a user to select a location (ie state or city) which then shows them all of the posts for those cities/states. I have part of this working, but what I'm really trying to figure out is where I should store such a variable and how.
I know, in theory, what I'm after on the code:
I've seen a few posts that seem similar, like This one and a few others talking about application.yml
variables, but these don't seem to be user defined if I understand correctly.
One other idea that I've seen is storing this variable in a user session, but I don't want all visitors to have to login in order for this functionality.
Any direction would be much appreciated!
You don't need to login to create a session. I suggest you use a user session without login to handle this stuff, and maybe even use a geolocation gem to get automatically the city/state and let the user switch if he wants to.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.