diff --git a/app/views/cities/index.html.erb b/app/views/cities/index.html.erb index 357e0b8..c72a81a 100644 --- a/app/views/cities/index.html.erb +++ b/app/views/cities/index.html.erb @@ -19,7 +19,7 @@ <% end %>
-

<%= city.name %>

+

<%= city.localized_name %>

Lat: <%= city.latitude %>

Long: <%= city.longitude %>

diff --git a/app/views/cities/show.html.erb b/app/views/cities/show.html.erb index f106856..c3b1f80 100644 --- a/app/views/cities/show.html.erb +++ b/app/views/cities/show.html.erb @@ -17,7 +17,7 @@ <% end %> -

<%= @city.name %>

+

<%= @city.localized_name %>

diff --git a/db/schema.rb b/db/schema.rb index 2a28d50..3862182 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,13 +11,16 @@ # 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 + # 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| t.string "namespace" t.text "body" t.string "resource_type" - t.integer "resource_id" + t.bigint "resource_id" t.string "author_type" - t.integer "author_id" + t.bigint "author_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false 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 "updated_at", null: false 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 ["slug"], name: "index_cities_on_slug", unique: true end @@ -86,7 +89,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_01_21_020653) do t.string "name" t.string "code" t.string "slug" - t.integer "region_id", null: false + t.bigint "region_id", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false 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 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.string "description" t.decimal "temperature" diff --git a/db/seeds.rb b/db/seeds.rb index e4dfc6d..f98b0eb 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -70,7 +70,6 @@ regions = Region.create!([ } ]) asia = Region.find_by(code: 'AS') -south_asia = Region.find_by(code: 'SA') africa = Region.find_by(code: 'AF') europe = Region.find_by(code: 'EU') north_america = Region.find_by(code: 'NAM') @@ -87,9 +86,9 @@ Country.create!([ { name: 'Hong Kong', code: 'HK', region: asia }, # South Asia - { name: 'India', code: 'IN', region: south_asia }, - { name: 'Pakistan', code: 'PK', region: south_asia }, - { name: 'Bangladesh', code: 'BD', region: south_asia }, + { name: 'India', code: 'IN', region: asia }, + { name: 'Pakistan', code: 'PK', region: asia }, + { name: 'Bangladesh', code: 'BD', region: asia }, # Southeast Asia { name: 'Indonesia', code: 'ID', region: asia }, @@ -97,7 +96,6 @@ Country.create!([ { name: 'Thailand', code: 'TH', region: asia }, { name: 'Myanmar', code: 'MM', region: asia }, { name: 'Singapore', code: 'SG', region: asia }, - { name: 'Bangladesh', code: 'BD', region: asia }, # Middle East { name: 'Turkey', code: 'TR', region: asia }, @@ -115,13 +113,12 @@ Country.create!([ { name: 'Angola', code: 'AO', region: africa }, { name: 'Mali', code: 'ML', region: africa }, { name: 'Ivory Coast', code: 'CI', region: africa }, - { name: 'Egypt', code: 'EGY', region: africa }, # Europe { name: 'Russia', code: 'RU', region: europe }, { name: 'United Kingdom', code: 'GB', region: europe }, { name: 'Germany', code: 'DE', region: europe }, - { name: 'France', code: 'FRA', region: europe}, + { name: 'France', code: 'FRA', region: europe }, # North America { name: 'United States', code: 'US', region: north_america }, @@ -133,7 +130,6 @@ Country.create!([ { name: 'Peru', code: 'PE', region: south_america }, { name: 'Colombia', code: 'CO', region: south_america }, { name: 'Chile', code: 'CL', region: south_america }, - { name: 'Brazil', code: 'BZ', region: south_america }, # 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 end -china = Country.find_by(code: 'CHN') +china = Country.find_by(code: 'CN') guangzhou = City.create!( name: 'Guangzhou', latitude: 23.1291, diff --git a/db/seeds/cities/australia.rb b/db/seeds/cities/australia.rb index 839fdf7..8f0468e 100644 --- a/db/seeds/cities/australia.rb +++ b/db/seeds/cities/australia.rb @@ -23,4 +23,4 @@ City.create!([ last_weather_fetch: 10.hours.ago, last_image_generation: 10.hours.ago } -]) \ No newline at end of file +]) diff --git a/db/seeds/cities/bangladesh.rb b/db/seeds/cities/bangladesh.rb index de70562..2d05cd7 100644 --- a/db/seeds/cities/bangladesh.rb +++ b/db/seeds/cities/bangladesh.rb @@ -12,4 +12,4 @@ City.create!([ last_weather_fetch: 10.hours.ago, last_image_generation: 10.hours.ago } -]) \ No newline at end of file +]) diff --git a/db/seeds/cities/brazil.rb b/db/seeds/cities/brazil.rb index d76851c..7634c82 100644 --- a/db/seeds/cities/brazil.rb +++ b/db/seeds/cities/brazil.rb @@ -1,4 +1,4 @@ -brazil = Country.find_by code: 'BZ' +brazil = Country.find_by code: 'BR' City.create!([ { @@ -12,4 +12,4 @@ City.create!([ last_weather_fetch: 10.hours.ago, last_image_generation: 10.hours.ago } -]) \ No newline at end of file +]) diff --git a/db/seeds/cities/canada.rb b/db/seeds/cities/canada.rb index 8a64e1e..83f01c0 100644 --- a/db/seeds/cities/canada.rb +++ b/db/seeds/cities/canada.rb @@ -9,4 +9,4 @@ City.create!( active: true, last_weather_fetch: 10.hours.ago, last_image_generation: 10.hours.ago -) \ No newline at end of file +) diff --git a/db/seeds/cities/china.rb b/db/seeds/cities/china.rb index e630d78..9b51b94 100644 --- a/db/seeds/cities/china.rb +++ b/db/seeds/cities/china.rb @@ -419,4 +419,4 @@ City.create!([ last_weather_fetch: 10.hours.ago, last_image_generation: 10.hours.ago } -]) \ No newline at end of file +]) diff --git a/db/seeds/cities/egypt.rb b/db/seeds/cities/egypt.rb index 1535830..2af57ae 100644 --- a/db/seeds/cities/egypt.rb +++ b/db/seeds/cities/egypt.rb @@ -1,4 +1,4 @@ -egypt = Country.find_by code: 'EGY' +egypt = Country.find_by code: 'EG' City.create!([ { @@ -12,4 +12,4 @@ City.create!([ last_weather_fetch: 10.hours.ago, last_image_generation: 10.hours.ago } -]) \ No newline at end of file +]) diff --git a/db/seeds/cities/france.rb b/db/seeds/cities/france.rb index 296778e..6088fc1 100644 --- a/db/seeds/cities/france.rb +++ b/db/seeds/cities/france.rb @@ -12,4 +12,4 @@ City.create!([ last_weather_fetch: 10.hours.ago, last_image_generation: 10.hours.ago } -]) \ No newline at end of file +]) diff --git a/db/seeds/cities/germany.rb b/db/seeds/cities/germany.rb index 16433bf..52e0f57 100644 --- a/db/seeds/cities/germany.rb +++ b/db/seeds/cities/germany.rb @@ -23,4 +23,4 @@ City.create!([ last_weather_fetch: 10.hours.ago, last_image_generation: 10.hours.ago } -]) \ No newline at end of file +]) diff --git a/db/seeds/cities/india.rb b/db/seeds/cities/india.rb index 17fd3ab..1f1b523 100644 --- a/db/seeds/cities/india.rb +++ b/db/seeds/cities/india.rb @@ -23,4 +23,4 @@ City.create!([ last_weather_fetch: 10.hours.ago, last_image_generation: 10.hours.ago } -]) \ No newline at end of file +]) diff --git a/db/seeds/cities/japan.rb b/db/seeds/cities/japan.rb index 6abce7e..6601b9c 100644 --- a/db/seeds/cities/japan.rb +++ b/db/seeds/cities/japan.rb @@ -1,4 +1,4 @@ -japan = Country.find_by 1 +japan = Country.find_by code: 'JP' City.create!([ { @@ -23,4 +23,4 @@ City.create!([ last_weather_fetch: 10.hours.ago, last_image_generation: 10.hours.ago } -]) \ No newline at end of file +]) diff --git a/db/seeds/cities/mexico.rb b/db/seeds/cities/mexico.rb index 46cfade..4f8747c 100644 --- a/db/seeds/cities/mexico.rb +++ b/db/seeds/cities/mexico.rb @@ -1,4 +1,4 @@ -mexico = Country.find_by 1 +mexico = Country.find_by code: 'MX' City.create!([ { @@ -12,4 +12,4 @@ City.create!([ last_weather_fetch: 10.hours.ago, last_image_generation: 10.hours.ago } -]) \ No newline at end of file +]) diff --git a/db/seeds/cities/nigeria.rb b/db/seeds/cities/nigeria.rb index 2ddcd5d..ab44ef6 100644 --- a/db/seeds/cities/nigeria.rb +++ b/db/seeds/cities/nigeria.rb @@ -1,4 +1,4 @@ -nigeria = Country.find_by 1 +nigeria = Country.find_by code: 'NG' City.create!([ { @@ -12,4 +12,4 @@ City.create!([ last_weather_fetch: 10.hours.ago, last_image_generation: 10.hours.ago } -]) \ No newline at end of file +]) diff --git a/db/seeds/cities/pakistan.rb b/db/seeds/cities/pakistan.rb index dd2b87d..6807e4e 100644 --- a/db/seeds/cities/pakistan.rb +++ b/db/seeds/cities/pakistan.rb @@ -1,4 +1,4 @@ -pakistan = Country.find_by 1 +pakistan = Country.find_by code: 'PK' City.create!([ { @@ -12,4 +12,4 @@ City.create!([ last_weather_fetch: 10.hours.ago, last_image_generation: 10.hours.ago } -]) \ No newline at end of file +]) diff --git a/db/seeds/cities/russia.rb b/db/seeds/cities/russia.rb index 71ee201..fb15784 100644 --- a/db/seeds/cities/russia.rb +++ b/db/seeds/cities/russia.rb @@ -1,4 +1,4 @@ -russia = Country.find_by 1 +russia = Country.find_by code: 'RU' City.create!([ { @@ -23,4 +23,4 @@ City.create!([ last_weather_fetch: 10.hours.ago, last_image_generation: 10.hours.ago } -]) \ No newline at end of file +]) diff --git a/db/seeds/cities/saudi_arabia.rb b/db/seeds/cities/saudi_arabia.rb index 08bcf9f..cbd407a 100644 --- a/db/seeds/cities/saudi_arabia.rb +++ b/db/seeds/cities/saudi_arabia.rb @@ -1,4 +1,4 @@ -saudi_arabia = Country.find_by 1 +saudi_arabia = Country.find_by code: 'CA' City.create!([ { @@ -12,4 +12,4 @@ City.create!([ last_weather_fetch: 10.hours.ago, last_image_generation: 10.hours.ago } -]) \ No newline at end of file +]) diff --git a/db/seeds/cities/singapore.rb b/db/seeds/cities/singapore.rb index 384645d..bd64433 100644 --- a/db/seeds/cities/singapore.rb +++ b/db/seeds/cities/singapore.rb @@ -1,4 +1,4 @@ -singapore = Country.find_by 1 +singapore = Country.find_by code: 'SG' City.create!([ { @@ -12,4 +12,4 @@ City.create!([ last_weather_fetch: 10.hours.ago, last_image_generation: 10.hours.ago } -]) \ No newline at end of file +]) diff --git a/db/seeds/cities/south_korea.rb b/db/seeds/cities/south_korea.rb index 2ecdd17..7398f3f 100644 --- a/db/seeds/cities/south_korea.rb +++ b/db/seeds/cities/south_korea.rb @@ -1,4 +1,4 @@ -south_korea = Country.find_by 1 +south_korea = Country.find_by code: 'KR' City.create!([ { @@ -12,4 +12,4 @@ City.create!([ last_weather_fetch: 10.hours.ago, last_image_generation: 10.hours.ago } -]) \ No newline at end of file +]) diff --git a/db/seeds/cities/thailand.rb b/db/seeds/cities/thailand.rb index 8914fe9..c62c18a 100644 --- a/db/seeds/cities/thailand.rb +++ b/db/seeds/cities/thailand.rb @@ -1,4 +1,4 @@ -thailand = Country.find_by 1 +thailand = Country.find_by code: 'TH' City.create!([ { @@ -12,4 +12,4 @@ City.create!([ last_weather_fetch: 10.hours.ago, last_image_generation: 10.hours.ago } -]) \ No newline at end of file +]) diff --git a/db/seeds/cities/turkey.rb b/db/seeds/cities/turkey.rb index 1a47f69..909b944 100644 --- a/db/seeds/cities/turkey.rb +++ b/db/seeds/cities/turkey.rb @@ -1,4 +1,4 @@ -turkey = Country.find_by 1 +turkey = Country.find_by code: 'TR' City.create!([ { @@ -23,4 +23,4 @@ City.create!([ last_weather_fetch: 10.hours.ago, last_image_generation: 10.hours.ago } -]) \ No newline at end of file +]) diff --git a/db/seeds/cities/uk.rb b/db/seeds/cities/uk.rb index 2692782..4bd8117 100644 --- a/db/seeds/cities/uk.rb +++ b/db/seeds/cities/uk.rb @@ -1,4 +1,4 @@ -uk = Country.find_by 1 +uk = Country.find_by code: 'GB' City.create!([ { @@ -12,4 +12,4 @@ City.create!([ last_weather_fetch: 10.hours.ago, last_image_generation: 10.hours.ago } -]) \ No newline at end of file +]) diff --git a/db/seeds/cities/usa.rb b/db/seeds/cities/usa.rb index 91f9eb3..012d53a 100644 --- a/db/seeds/cities/usa.rb +++ b/db/seeds/cities/usa.rb @@ -1,4 +1,4 @@ -usa = Country.find_by 1 +usa = Country.find_by code: 'US' City.create!([ { @@ -45,4 +45,4 @@ City.create!([ last_weather_fetch: 10.hours.ago, last_image_generation: 10.hours.ago } -]) \ No newline at end of file +]) diff --git a/db/seeds/cities/vietnam.rb b/db/seeds/cities/vietnam.rb index 43cfd86..fed8650 100644 --- a/db/seeds/cities/vietnam.rb +++ b/db/seeds/cities/vietnam.rb @@ -1,4 +1,4 @@ -vietnam = Country.find_by 1 +vietnam = Country.find_by code: 'VN' City.create!([ {