today_ai_weather/db/seeds.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

45 lines
1.5 KiB
Ruby

# This file should ensure the existence of records required to run the application in every environment (production,
# development, test). The code here should be idempotent so that it can be executed at any point in every environment.
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
#
# Example:
#
# ["Action", "Comedy", "Drama", "Horror"].each do |genre_name|
# MovieGenre.find_or_create_by!(name: genre_name)
# end
AdminUser.create!(email: 'admin@example.com', password: 'password', password_confirmation: 'password') if Rails.env.development?
guangzhou = City.create!(
name: 'Guangzhou',
country: 'China',
latitude: 23.1291,
longitude: 113.2644,
active: true,
priority: 50,
timezone: 'Asia/Shanghai',
region: 'Asia',
last_weather_fetch: 10.hours.ago,
last_image_generation: 10.hours.ago
)
guangzhou_weather_art = WeatherArt.create!(
city: guangzhou,
weather_date: Date.today,
description: 'Sunny with some clouds',
temperature: 28.5,
feeling_temp: 30.2,
humidity: 65,
wind_scale: "3级",
wind_speed: 15,
precipitation: 0,
pressure: 1013,
visibility: 10,
cloud: 30,
prompt: "A sunny day in Guangzhou with modern buildings under blue sky and white clouds, digital art style"
)
guangzhou_weather_art.image.attach(
io: File.open("db/seeds/images/sample-guangzhou-weather-art.png"),
filename: "sample-guangzhou-weather-art.png",
content_type: "image/png"
)