feat: add country filter to cities controller

- Introduce filtering of cities by selected country
- Retrieve current country using friendly find method
- Apply city filtering if country is provided in parameters

This change allows users to efficiently filter cities based on the
selected country, providing a more tailored experience and
encouraging better navigation through the list of cities.
This commit is contained in:
songtianlun 2025-02-12 15:12:23 +08:00
parent a1f1f2b728
commit 940f1a8f76

View File

@ -15,6 +15,11 @@ class CitiesController < ApplicationController
@cities = @cities.by_region(@current_region.id) if @current_region
end
if params[:country]
@current_country = Country.friendly.find(params[:country])
@cities = @cities.by_country(@current_country.id) if @current_country
end
@cities = @cities.page(params[:page]).per(12)
respond_to do |format|