2025-01-19 12:21:00 +08:00
|
|
|
class CitiesController < ApplicationController
|
|
|
|
def index
|
2025-01-19 22:08:05 +08:00
|
|
|
@cities = City.all.order(:name)
|
2025-01-22 14:04:58 +08:00
|
|
|
@regions = Region.includes(:countries).order(:name)
|
|
|
|
@cities = City.includes(:country, country: :region).active.order(:name)
|
|
|
|
|
|
|
|
if params[:region]
|
|
|
|
@current_region = Region.friendly.find(params[:region])
|
|
|
|
@cities = @cities.by_region(@current_region.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
if params[:country]
|
|
|
|
@current_country = Country.friendly.find(params[:country])
|
|
|
|
@cities = @cities.by_country(@current_country.id)
|
|
|
|
end
|
2025-01-19 12:21:00 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
2025-01-19 22:08:05 +08:00
|
|
|
@city = City.friendly.find(params[:id])
|
2025-01-19 12:21:00 +08:00
|
|
|
end
|
|
|
|
end
|