2025-01-19 12:21:00 +08:00
class CitiesController < ApplicationController
def index
2025-01-22 14:04:58 +08:00
@regions = Region . includes ( :countries ) . order ( :name )
2025-01-26 23:49:35 +08:00
@cities = City . includes ( :country , country : :region ) . order ( :name )
2025-01-22 14:04:58 +08:00
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-23 17:30:05 +08:00
@cities = @cities . page ( params [ :page ] ) . per ( 10 )
2025-01-23 19:02:52 +08:00
set_meta_tags (
title : @current_region ? " Cities in #{ @current_region . name } " : " Explore Cities " ,
description : " Discover weather art for cities #{ @current_region ? " in #{ @current_region . name } " : 'worldwide' } . Real-time AI-generated weather visualization. " ,
keywords : " #{ @current_region & . name } , cities, weather art, AI visualization "
)
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-27 00:43:18 +08:00
ahoy . track " View City " , {
city_id : @city . id ,
name : @city . name ,
2025-01-27 00:43:36 +08:00
event_type : " city_view "
2025-01-27 00:43:18 +08:00
}
2025-01-23 19:02:52 +08:00
set_meta_tags (
title : @city . name ,
description : " Experience #{ @city . name } 's weather through AI-generated art. Daily updates of weather conditions visualized through artificial intelligence. " ,
keywords : " #{ @city . name } , #{ @city . country . name } , weather art, AI visualization " ,
og : {
image : @city . latest_weather_art & . image & . attached? ? url_for ( @city . latest_weather_art . image ) : nil
}
)
2025-01-19 12:21:00 +08:00
end
end