songtianlun
50321533f7
- Removed unnecessary leading and trailing blank lines in several ActiveAdmin register files. - Reformatted string delimiters for consistency, changing single quotes to double quotes in tracking events in the Cities and WeatherArts controllers. - Ensured proper spacing in array definitions across several models, including Ahoy::Event and Ahoy::Visit. These changes improve code readability and maintain consistency throughout the codebase by ensuring uniform use of quotes and removing excess whitespace.
43 lines
1.5 KiB
Ruby
43 lines
1.5 KiB
Ruby
class CitiesController < ApplicationController
|
|
def index
|
|
@regions = Region.includes(:countries).order(:name)
|
|
@cities = City.includes(:country, country: :region).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
|
|
|
|
@cities = @cities.page(params[:page]).per(10)
|
|
|
|
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"
|
|
)
|
|
end
|
|
|
|
def show
|
|
@city = City.friendly.find(params[:id])
|
|
ahoy.track "View City", {
|
|
city_id: @city.id,
|
|
name: @city.name,
|
|
event_type: "city_view"
|
|
}
|
|
|
|
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
|
|
}
|
|
)
|
|
end
|
|
end
|