Reputation: 2397
My people index page receives a parameter called city_name. If city_name is valid and unambiguous, it shows all people from that city. However, if city_name parameter matches more than one city, I want to display a screen to the user telling him to choose the desired city (then he's redirected back to people's index action with the unambigous query).
What's the proper way to do it? Should I create an action called choose in my PeopleController and redirect to it whenever city_name is ambiguous?
Upvotes: 0
Views: 77
Reputation: 9722
I think a better way to do it is to restrict user to selecting only one option using the select tag. It avoids a server-trip for something as simple as selecting only one option. If you prefer it to do it on the server-side for some reason, then you simply display the flash message:
flash[:notice] = "Please select only one city"
And stay on the same index page till you get only one city.
Upvotes: 1