S
S
SergeyMina2015-09-08 20:40:01
Ruby on Rails
SergeyMina, 2015-09-08 20:40:01

What is the correct way to implement city change functionality in Ruby on Rails?

Hello. I'm going to create a new thread for this question because I can't figure it out.
There is a "sypexgeo_method_city" method in the controller that returns the city by IP. Then I use this method like this

@data = Model....where( city: sypexgeo_method_city )

Those. the data sample directly depends on the city.
As I was told, if the client changed the city, it should be stored in localStorage. Made. Before that, I stored in the session. Now this is no longer an option.
The question is actually what. Every time the client refreshes the page, you have to make a post request and check for the presence of a city on the client, and only after that, depending on the city, load the data. Are there really no other options?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Dyachuk, 2015-09-13
@Renius

use a cookie to know if you checked for a city or not

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question