2024-12-29 17:12:54 +08:00
|
|
|
# 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
|
2025-01-05 17:50:33 +08:00
|
|
|
|
|
|
|
User.create!(name: "Example User",
|
|
|
|
email: "example@example.com",
|
|
|
|
password: "foobar",
|
2025-01-05 18:27:13 +08:00
|
|
|
password_confirmation: "foobar",
|
2025-01-06 18:38:39 +08:00
|
|
|
admin: true,
|
|
|
|
activated: true,
|
|
|
|
activated_at: Time.zone.now)
|
2025-01-05 17:50:33 +08:00
|
|
|
|
2025-01-18 21:42:31 +08:00
|
|
|
9.times do |n|
|
2025-01-05 17:50:33 +08:00
|
|
|
name = Faker::Name.name
|
|
|
|
email = "example-#{n+1}@railstutorial.org"
|
|
|
|
password = "password"
|
|
|
|
User.create!(name: name,
|
|
|
|
email: email,
|
|
|
|
password: password,
|
2025-01-06 18:38:39 +08:00
|
|
|
password_confirmation: password,
|
|
|
|
activated: true,
|
|
|
|
activated_at: Time.zone.now)
|
2025-01-05 17:50:33 +08:00
|
|
|
end
|
2025-01-18 21:42:31 +08:00
|
|
|
|
|
|
|
City.create!(
|
|
|
|
name: "Guangzhou",
|
|
|
|
country: "China",
|
|
|
|
latitude: 23.125178,
|
|
|
|
longitude: 113.280637,
|
|
|
|
featured: true,
|
|
|
|
)
|
|
|
|
|
|
|
|
sample_art = WeatherArt.create!(
|
|
|
|
city_id: City.first.id,
|
|
|
|
weather_date: Time.zone.today,
|
|
|
|
description: "Sunny",
|
|
|
|
temperature: 21,
|
|
|
|
feeling_temp: 19,
|
|
|
|
humidity: 28,
|
|
|
|
wind_scale: 2,
|
|
|
|
wind_speed: 8,
|
|
|
|
precipitation: 0.0,
|
|
|
|
pressure: 1008,
|
|
|
|
visibility: 30,
|
|
|
|
cloud: 0,
|
|
|
|
prompt: "Artistic sunny weather in Guangzhou"
|
|
|
|
)
|
|
|
|
|
|
|
|
sample_art.image.attach(
|
|
|
|
io: File.open("db/seeds/images/sample_guangzhou_weather_art.png"),
|
|
|
|
filename: "sample_guangzhou_art.png",
|
|
|
|
content_type: "image/png"
|
|
|
|
)
|