today_ai_weather/app/models/city.rb
songtianlun 8e8c60254f feat: add cities feature with weather arts
- Implement CitiesController for listing and showing cities
- Create City and WeatherArt models with associations
- Add views for cities index and show, displaying weather arts
- Include routes for cities and active storage for images
- Update migrations for weather arts and seed data for testing

This commit introduces a comprehensive cities feature that allows users to view cities along with their associated weather art. The implementation includes necessary database migrations, routes, and controller actions to support this new functionality.
2025-01-18 21:42:31 +08:00

14 lines
280 B
Ruby

class City < ApplicationRecord
has_many :weather_arts
scope :featured, -> { where(featured: true) }
def current_weather_art
weather_arts.find_by(weather_date: Date.current)
end
def weather_art_for_date(date)
weather_arts.find_by(weather_date: date)
end
end