feat: update city display and database schema
- Change city name display to localized name in both index and show views - Modify schema to use bigint for certain foreign keys - Correct country codes in seeds for accurate data representation These changes improve the handling of city names, ensuring they are displayed in the appropriate localized format and ensuring well-typed foreign key relationships in the schema.
This commit is contained in:
parent
ebaf7a3f34
commit
c11d10c86a
@ -19,7 +19,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="card-body relative">
|
<div class="card-body relative">
|
||||||
<h2 class="card-title font-display text-2xl"><%= city.name %></h2>
|
<h2 class="card-title font-display text-2xl"><%= city.localized_name %></h2>
|
||||||
<div class="text-base-content/70">
|
<div class="text-base-content/70">
|
||||||
<p>Lat: <%= city.latitude %></p>
|
<p>Lat: <%= city.latitude %></p>
|
||||||
<p>Long: <%= city.longitude %></p>
|
<p>Long: <%= city.longitude %></p>
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" />
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" />
|
||||||
</svg>
|
</svg>
|
||||||
<% end %>
|
<% end %>
|
||||||
<h1 class="text-4xl md:text-5xl font-display font-bold"><%= @city.name %></h1>
|
<h1 class="text-4xl md:text-5xl font-display font-bold"><%= @city.localized_name %></h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="stats bg-base-100/80 backdrop-blur-sm shadow">
|
<div class="stats bg-base-100/80 backdrop-blur-sm shadow">
|
||||||
|
13
db/schema.rb
generated
13
db/schema.rb
generated
@ -11,13 +11,16 @@
|
|||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[8.0].define(version: 2025_01_21_020653) do
|
ActiveRecord::Schema[8.0].define(version: 2025_01_21_020653) do
|
||||||
|
# These are extensions that must be enabled in order to support this database
|
||||||
|
enable_extension "pg_catalog.plpgsql"
|
||||||
|
|
||||||
create_table "active_admin_comments", force: :cascade do |t|
|
create_table "active_admin_comments", force: :cascade do |t|
|
||||||
t.string "namespace"
|
t.string "namespace"
|
||||||
t.text "body"
|
t.text "body"
|
||||||
t.string "resource_type"
|
t.string "resource_type"
|
||||||
t.integer "resource_id"
|
t.bigint "resource_id"
|
||||||
t.string "author_type"
|
t.string "author_type"
|
||||||
t.integer "author_id"
|
t.bigint "author_id"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.index ["author_type", "author_id"], name: "index_active_admin_comments_on_author"
|
t.index ["author_type", "author_id"], name: "index_active_admin_comments_on_author"
|
||||||
@ -77,7 +80,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_01_21_020653) do
|
|||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.string "slug"
|
t.string "slug"
|
||||||
t.integer "country_id", null: false
|
t.bigint "country_id", null: false
|
||||||
t.index ["country_id"], name: "index_cities_on_country_id"
|
t.index ["country_id"], name: "index_cities_on_country_id"
|
||||||
t.index ["slug"], name: "index_cities_on_slug", unique: true
|
t.index ["slug"], name: "index_cities_on_slug", unique: true
|
||||||
end
|
end
|
||||||
@ -86,7 +89,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_01_21_020653) do
|
|||||||
t.string "name"
|
t.string "name"
|
||||||
t.string "code"
|
t.string "code"
|
||||||
t.string "slug"
|
t.string "slug"
|
||||||
t.integer "region_id", null: false
|
t.bigint "region_id", null: false
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.index ["code"], name: "index_countries_on_code", unique: true
|
t.index ["code"], name: "index_countries_on_code", unique: true
|
||||||
@ -116,7 +119,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_01_21_020653) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
create_table "weather_arts", force: :cascade do |t|
|
create_table "weather_arts", force: :cascade do |t|
|
||||||
t.integer "city_id", null: false
|
t.bigint "city_id", null: false
|
||||||
t.date "weather_date"
|
t.date "weather_date"
|
||||||
t.string "description"
|
t.string "description"
|
||||||
t.decimal "temperature"
|
t.decimal "temperature"
|
||||||
|
12
db/seeds.rb
12
db/seeds.rb
@ -70,7 +70,6 @@ regions = Region.create!([
|
|||||||
}
|
}
|
||||||
])
|
])
|
||||||
asia = Region.find_by(code: 'AS')
|
asia = Region.find_by(code: 'AS')
|
||||||
south_asia = Region.find_by(code: 'SA')
|
|
||||||
africa = Region.find_by(code: 'AF')
|
africa = Region.find_by(code: 'AF')
|
||||||
europe = Region.find_by(code: 'EU')
|
europe = Region.find_by(code: 'EU')
|
||||||
north_america = Region.find_by(code: 'NAM')
|
north_america = Region.find_by(code: 'NAM')
|
||||||
@ -87,9 +86,9 @@ Country.create!([
|
|||||||
{ name: 'Hong Kong', code: 'HK', region: asia },
|
{ name: 'Hong Kong', code: 'HK', region: asia },
|
||||||
|
|
||||||
# South Asia
|
# South Asia
|
||||||
{ name: 'India', code: 'IN', region: south_asia },
|
{ name: 'India', code: 'IN', region: asia },
|
||||||
{ name: 'Pakistan', code: 'PK', region: south_asia },
|
{ name: 'Pakistan', code: 'PK', region: asia },
|
||||||
{ name: 'Bangladesh', code: 'BD', region: south_asia },
|
{ name: 'Bangladesh', code: 'BD', region: asia },
|
||||||
|
|
||||||
# Southeast Asia
|
# Southeast Asia
|
||||||
{ name: 'Indonesia', code: 'ID', region: asia },
|
{ name: 'Indonesia', code: 'ID', region: asia },
|
||||||
@ -97,7 +96,6 @@ Country.create!([
|
|||||||
{ name: 'Thailand', code: 'TH', region: asia },
|
{ name: 'Thailand', code: 'TH', region: asia },
|
||||||
{ name: 'Myanmar', code: 'MM', region: asia },
|
{ name: 'Myanmar', code: 'MM', region: asia },
|
||||||
{ name: 'Singapore', code: 'SG', region: asia },
|
{ name: 'Singapore', code: 'SG', region: asia },
|
||||||
{ name: 'Bangladesh', code: 'BD', region: asia },
|
|
||||||
|
|
||||||
# Middle East
|
# Middle East
|
||||||
{ name: 'Turkey', code: 'TR', region: asia },
|
{ name: 'Turkey', code: 'TR', region: asia },
|
||||||
@ -115,7 +113,6 @@ Country.create!([
|
|||||||
{ name: 'Angola', code: 'AO', region: africa },
|
{ name: 'Angola', code: 'AO', region: africa },
|
||||||
{ name: 'Mali', code: 'ML', region: africa },
|
{ name: 'Mali', code: 'ML', region: africa },
|
||||||
{ name: 'Ivory Coast', code: 'CI', region: africa },
|
{ name: 'Ivory Coast', code: 'CI', region: africa },
|
||||||
{ name: 'Egypt', code: 'EGY', region: africa },
|
|
||||||
|
|
||||||
# Europe
|
# Europe
|
||||||
{ name: 'Russia', code: 'RU', region: europe },
|
{ name: 'Russia', code: 'RU', region: europe },
|
||||||
@ -133,7 +130,6 @@ Country.create!([
|
|||||||
{ name: 'Peru', code: 'PE', region: south_america },
|
{ name: 'Peru', code: 'PE', region: south_america },
|
||||||
{ name: 'Colombia', code: 'CO', region: south_america },
|
{ name: 'Colombia', code: 'CO', region: south_america },
|
||||||
{ name: 'Chile', code: 'CL', region: south_america },
|
{ name: 'Chile', code: 'CL', region: south_america },
|
||||||
{ name: 'Brazil', code: 'BZ', region: south_america },
|
|
||||||
|
|
||||||
# Oceania
|
# Oceania
|
||||||
{ name: 'Australia', code: 'AU', region: oceania }
|
{ name: 'Australia', code: 'AU', region: oceania }
|
||||||
@ -144,7 +140,7 @@ Dir[Rails.root.join('db/seeds/cities/*.rb')].sort.each do |file|
|
|||||||
require file
|
require file
|
||||||
end
|
end
|
||||||
|
|
||||||
china = Country.find_by(code: 'CHN')
|
china = Country.find_by(code: 'CN')
|
||||||
guangzhou = City.create!(
|
guangzhou = City.create!(
|
||||||
name: 'Guangzhou',
|
name: 'Guangzhou',
|
||||||
latitude: 23.1291,
|
latitude: 23.1291,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
brazil = Country.find_by code: 'BZ'
|
brazil = Country.find_by code: 'BR'
|
||||||
|
|
||||||
City.create!([
|
City.create!([
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
egypt = Country.find_by code: 'EGY'
|
egypt = Country.find_by code: 'EG'
|
||||||
|
|
||||||
City.create!([
|
City.create!([
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
japan = Country.find_by 1
|
japan = Country.find_by code: 'JP'
|
||||||
|
|
||||||
City.create!([
|
City.create!([
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
mexico = Country.find_by 1
|
mexico = Country.find_by code: 'MX'
|
||||||
|
|
||||||
City.create!([
|
City.create!([
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
nigeria = Country.find_by 1
|
nigeria = Country.find_by code: 'NG'
|
||||||
|
|
||||||
City.create!([
|
City.create!([
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
pakistan = Country.find_by 1
|
pakistan = Country.find_by code: 'PK'
|
||||||
|
|
||||||
City.create!([
|
City.create!([
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
russia = Country.find_by 1
|
russia = Country.find_by code: 'RU'
|
||||||
|
|
||||||
City.create!([
|
City.create!([
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
saudi_arabia = Country.find_by 1
|
saudi_arabia = Country.find_by code: 'CA'
|
||||||
|
|
||||||
City.create!([
|
City.create!([
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
singapore = Country.find_by 1
|
singapore = Country.find_by code: 'SG'
|
||||||
|
|
||||||
City.create!([
|
City.create!([
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
south_korea = Country.find_by 1
|
south_korea = Country.find_by code: 'KR'
|
||||||
|
|
||||||
City.create!([
|
City.create!([
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
thailand = Country.find_by 1
|
thailand = Country.find_by code: 'TH'
|
||||||
|
|
||||||
City.create!([
|
City.create!([
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
turkey = Country.find_by 1
|
turkey = Country.find_by code: 'TR'
|
||||||
|
|
||||||
City.create!([
|
City.create!([
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
uk = Country.find_by 1
|
uk = Country.find_by code: 'GB'
|
||||||
|
|
||||||
City.create!([
|
City.create!([
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
usa = Country.find_by 1
|
usa = Country.find_by code: 'US'
|
||||||
|
|
||||||
City.create!([
|
City.create!([
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
vietnam = Country.find_by 1
|
vietnam = Country.find_by code: 'VN'
|
||||||
|
|
||||||
City.create!([
|
City.create!([
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user