baffling - datetime issue in app

11 views
Skip to first unread message

Allen Maxwell

unread,
Nov 10, 2015, 9:17:41 AM11/10/15
to ur...@googlegroups.com
Hi all,

I’ve got an app I’m working on and all the date fields in my database are showing up in ActiveRecord as nil… the records save fine in spite of validators that say things like created_at and updated_at must not be nil… but they are.

It’s not just the time stamps. All the date fields show as nil in the rails console. I don’t see that in my other projects. any ideas what could cause this?
It’s also not just on my dev machine. It’s doing this in production!

thanks,

Max

Allen Maxwell

unread,
Nov 10, 2015, 9:43:36 AM11/10/15
to ur...@googlegroups.com
follow up. when I go into postgres directly (psql) the datetime fields are populated correctly. The the problems is in rails.

they show up as nil in my views and in the rails console when I look at any records…

any ideas on this? weird….
> --
> http://utruby.org
> http://groups.google.com/group/urug
>
> please prefix the subject with [JOB] when regarding job opportunities
> ---
> You received this message because you are subscribed to the Google Groups "Utah Ruby Users Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to urug+uns...@googlegroups.com.
> To post to this group, send email to ur...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Allen Maxwell

unread,
Nov 10, 2015, 9:50:41 AM11/10/15
to ur...@googlegroups.com
sorry for the repeating posts - thought I should include:

Rails 4.2.1
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]

I’m using devise…. here’s my first user record (which you can see shows nil for the DateTime fields:

#<User id: 1, email: "allen....@bhghome.com", encrypted_password: “xxx", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 5, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: #<IPAddr: IPv4:127.0.0.1/255.255.255.255>, last_sign_in_ip: #<IPAddr: IPv4:67.2.206.242/255.255.255.255>, created_at: nil, updated_at: nil, authentication_token: “xxx", first_name: nil, last_name: nil, agent_no: nil, agent_office_name: nil, agent_office_no: nil, image_url: "https://lh6.googleusercontent.com/-Gd-hGJwcNe0/AAAxxx", thumbnail: "https://lh6.googleusercontent.com/-Gd-hGJwcNe0/AAAxxx", google_id: “xxxx", is_active: true>

Here’s another record from a different table:
#<SystemLog id: 1, occurred: nil, action: "Loading all Initialized Data", comment: "", created_at: nil, updated_at: nil>

here’s the table defs:

# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# email :string default(""), not null
# encrypted_password :string default(""), not null
# reset_password_token :string
# reset_password_sent_at :datetime
# remember_created_at :datetime
# sign_in_count :integer default(0), not null
# current_sign_in_at :datetime
# last_sign_in_at :datetime
# current_sign_in_ip :inet
# last_sign_in_ip :inet
# created_at :datetime not null
# updated_at :datetime not null
# authentication_token :text
# first_name :string
# last_name :string
# agent_no :string
# agent_office_name :string
# agent_office_no :string
# image_url :string
# thumbnail :string
# google_id :string
# is_active :boolean default(TRUE)
#


# == Schema Information
#
# Table name: system_logs
#
# id :integer not null, primary key
# occurred :datetime
# action :string
# comment :text
# created_at :datetime not null
# updated_at :datetime not null
#

I have a feeling this is something to do with Rails 4… or 4.2 but I can’t find anything in google so far…

thanks in advance for any help.


On Nov 10, 2015, at 7:16 AM, Allen Maxwell <aa...@xmission.com> wrote:

Allen Maxwell

unread,
Nov 10, 2015, 10:23:37 AM11/10/15
to ur...@googlegroups.com
This was weird enough I figured I’d let you know what I did.  and yes, of course it was me doing something stupid :)

I had the active_record.default_time_zone set to pacific time with the same time string you’d use to set the time zone.  Valid values are :local and :utc so that didn’t work out so well.  

If you ever run into that, I hope this helps.

Max
Reply all
Reply to author
Forward
0 new messages