我正在尝试将数据插入到我的TimeSlot表中。加班我运行代码,我得到这个错误" NoMethodError:未定义的方法`in_time_zone'为零:NilClass"
以下是插入数据的代码:
starts_at= begin_date
time_slot=TimeSlot.create( starts_at: '',
length: 15,
provider_id: '',
practice_location_id: '',
practice_id: '',
day_of_the_week: ' ',
timezone: "Central Time (US & Canada)",
hour_of_the_day: 1,
health_post_id: time_slot_start_health_post_id,
deleted_at: 'NULL',
health_post_url: url,
cached_reason_for_visits_list: "8~Allergic Asthma|9~Allergic Cough|10~Allergic Eye Problems|7~Allergy Consultation|5~Discharge (ER) Follow Up Visit|6~Discharge (Hospital) Follow Up Visit|11~Drug Allergy|12~Eczema|3~Follow Up – Established Patient|13~Food Intolerance|2~General Consultation|14~Hay Fever|15~Hives|1~New Patient|16~Poison Ivy|4~Sick Visit – Established Patient|17~Skin Rashes",
type_of_patient: "any_test")
以下是模型
中time_zone的功能 def local_starts_at
set_timezone unless self.timezone
@local_starts_at ||= self.starts_at.in_time_zone(self.timezone)
end
请帮忙。