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.
This commit is contained in:
songtianlun 2025-02-15 12:01:19 +08:00
parent 968efb5492
commit df074a81a8

View File

@ -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" }