City search should have the autocomplete functionality, i.e. it should list the matching cities as the user is typing the name.
Things to do:
- Install JQuery UI plugin.
- Add JS code to connect autocomplete to city search field.
- Add CSS styling to autocomplete elements.
- Create
City resource (CitiesController only needs index action which responds to json, City model consists of name and count and does not have its own table, it delegates queries to Address).
- Autocomplete list should display the name and the number of parkings for each city.
Explanation of flow:
- autocomplete JS code calls
/cities.json,
CitiesController#index method calls City.search method,
City.search method calls Address.with_city_like query, adds SQL grouping by city name and counting,
City.search method maps results of queries to City objects and returns them,
CitiesController#index method responds with city results, which are converted to JSON by Rails.
City search should have the autocomplete functionality, i.e. it should list the matching cities as the user is typing the name.
Things to do:
Cityresource (CitiesControlleronly needsindexaction which responds tojson,Citymodel consists of name and count and does not have its own table, it delegates queries toAddress).Explanation of flow:
/cities.json,CitiesController#indexmethod callsCity.searchmethod,City.searchmethod callsAddress.with_city_likequery, adds SQL grouping by city name and counting,City.searchmethod maps results of queries toCityobjects and returns them,CitiesController#indexmethod responds with city results, which are converted to JSON by Rails.