- Change ordering of previous weather art to use 'id' descending - Change ordering of next weather art to use 'id' ascending - Remove unnecessary blank line in seeds file These changes enhance the consistency of the weather art navigation by using 'id' for ordering, ensuring the correct retrieval of records.
37 lines
1.3 KiB
Ruby
37 lines
1.3 KiB
Ruby
class WeatherArtsController < ApplicationController
|
|
def show
|
|
@city = City.friendly.find(params[:city_id])
|
|
@weather_art = @city.weather_arts.friendly.find(params[:slug])
|
|
|
|
@previous_weather_art = @city.weather_arts
|
|
.where("id < ?", @weather_art.id)
|
|
.order(id: :desc)
|
|
.first
|
|
|
|
@next_weather_art = @city.weather_arts
|
|
.where("id > ?", @weather_art.id)
|
|
.order(id: :asc)
|
|
.first
|
|
|
|
ahoy.track "View Weather Art", {
|
|
weather_art_id: @weather_art.id,
|
|
city_id: @weather_art.city_id,
|
|
event_type: "weather_art_view"
|
|
}
|
|
ahoy.track "View City", {
|
|
city_id: @city.id,
|
|
name: @city.name,
|
|
event_type: "city_view"
|
|
}
|
|
|
|
set_meta_tags(
|
|
title: "#{@city.name} Weather Art - #{@weather_art.weather_date.strftime('%B %d, %Y')}",
|
|
description: "#{@city.name}'s weather visualized through AI art. #{@weather_art.description} at #{@weather_art.temperature}°C.",
|
|
keywords: "#{@city.name}, weather art, #{@weather_art.description}, AI visualization",
|
|
og: {
|
|
image: @weather_art.image.attached? ? url_for(@weather_art.image) : nil
|
|
}
|
|
)
|
|
end
|
|
end
|