Reputation: 798
I'm trying to figure out how to handle a user selecting a 'global' variable.
Specifically, I want a user to select a location (i.e. 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!
Upvotes: 0
Views: 67
Reputation: 20116
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.
Upvotes: 1