From df074a81a8372b177f16dce51b545b167fe1be4f Mon Sep 17 00:00:00 2001 From: songtianlun <tianlun.song@foxmail.com> Date: Sat, 15 Feb 2025 12:01:19 +0800 Subject: [PATCH] fix: access city attribute correctly in WeatherArt model - Modified the formatted_time method to use 'self' when accessing the city attribute - This change fixes a bug where the city attribute was not being accessed correctly, ensuring proper timezone information retrieval. --- app/models/weather_art.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/weather_art.rb b/app/models/weather_art.rb index 6c37484..01b3422 100644 --- a/app/models/weather_art.rb +++ b/app/models/weather_art.rb @@ -70,7 +70,7 @@ class WeatherArt < ApplicationRecord def formatted_time(type = :date, use_local_timezone = false) # 获取时区 - timezone_info = city&.country&.timezones.present? ? + timezone_info = self.city&.country&.timezones.present? ? eval(self.city.country.timezones).first : { "zoneName" => "UTC", "gmtOffsetName" => "UTC+00:00" }