Rails 4 model returns always nil

后端 未结 3 804
不知归路
不知归路 2021-01-14 03:02

I am going crazy with the following error. I have a User class and two of its attributes (birthday & created_at => datetime) returns always nil besides it has a value on

相关标签:
3条回答
  • 2021-01-14 03:23

    Had the same problem, and it was specifically

    config.active_record.default_timezone
    

    This caused activerecord to return all UTC-stored timestamps as null. Not sure why, but removing it brought back all data. I was able to leave default config.time_zone in place.

    0 讨论(0)
  • 2021-01-14 03:39

    config.active_record.default_timezone requires a symbol, either :local or :utc.

    config.time_zone requires a regular time zone as you have done.

    config.active_record.default_timezone determines whether to use Time.local (if set to :local) or Time.utc (if set to :utc) when pulling dates and times from the database. The default is :utc.

    http://guides.rubyonrails.org/configuring.html#configuring-active-record

    0 讨论(0)
  • 2021-01-14 03:40

    I found the problem.

    Some days ago I changed the config/application.rb file adding the following configuration to solve some issues with timezones:

    config.time_zone and config.active_record.default_timezone
    

    I've just removed them and all is working fine again.

    0 讨论(0)
提交回复
热议问题