today_ai_weather/app/models/weather_art.rb
songtianlun e5743a5e3f feat: add friendly_id for cities and weather arts
- Integrate 'friendly_id' gem for sluggable functionality in City model
- Create ActiveAdmin resources for managing cities and weather arts
- Implement controller logic for cities
- Add database migrations for cities and weather arts creation
- Seed database with sample data for testing
- Create initial test cases for controllers and models

This commit enhances the application's URL handling by allowing friendly URLs for cities and weather arts. The addition of ActiveAdmin resources facilitates easier management through a web interface.
2025-01-19 12:21:00 +08:00

17 lines
564 B
Ruby

class WeatherArt < ApplicationRecord
belongs_to :city
has_one_attached :image
validates :weather_date, presence: true
validates :city_id, presence: true
def self.ransackable_associations(auth_object = nil)
["city", "image_attachment", "image_blob"]
end
def self.ransackable_attributes(auth_object = nil)
[ "city_id", "cloud", "created_at", "description", "feeling_temp", "humidity", "id", "id_value", "precipitation", "pressure", "prompt", "temperature", "updated_at", "visibility", "weather_date", "wind_scale", "wind_speed" ]
end
end