Created_at Exists In DB But AR Object created_at is nil?

This one seems very strange to me.

I have a AR object that has the created_at/updated_at columns. They
populate
fine and they are in the DB row:

LOG: statement: select id, created_at from locations where id = 7632;
id | created_at
------±--------------------
7632 | 2006-05-22 21:12:20

Problem is, when I find the object in Rails, the created_at column is
nil.

location = Location.find(7632)
logger.debug “Location: #{ location .to_xml}”

Prints out:

7632 ... Snip other stuff ...

And doing location.created.blank? returns true. It’s nil.

Huh? It’s in the database and I am finding the row but AR is returning
nil
for the column. It’s not making a lot of sense to me and I’ve never seen
this issue before.

Anyone have any ideas? I’m running on 1.1.6 / Ruby 1.8.4 on MacOS X
Tiger
against PostgreSQL 8.1.

Thanks,
H

I’m getting the same thing

However if I render object.created_at in my view AFTER calling
object.something_else it is then populated

for example:
table users:
id | name | created_at
1 | james | 2006-05-22 21:12:20

in view:
<%= user.created_at %>
<%= user.name %>
renders:
james

the following:
<%= user.name %>
<%= user.created_at %>
renders:
james
2006-05-22 21:12:20

how odd!

it seems the entire row is not being loaded into the local object to
start with

are you getting this occuring in your code too??

rails 1.1.6 on windoze
webbrick and mongrel
mysql 5

HH wrote:

This one seems very strange to me.

I have a AR object that has the created_at/updated_at columns. They
populate
fine and they are in the DB row:

LOG: statement: select id, created_at from locations where id = 7632;
id | created_at
------±--------------------
7632 | 2006-05-22 21:12:20

Problem is, when I find the object in Rails, the created_at column is
nil.

location = Location.find(7632)
logger.debug “Location: #{ location .to_xml}”

Prints out:

7632 ... Snip other stuff ...

And doing location.created.blank? returns true. It’s nil.

Huh? It’s in the database and I am finding the row but AR is returning
nil
for the column. It’s not making a lot of sense to me and I’ve never seen
this issue before.

Anyone have any ideas? I’m running on 1.1.6 / Ruby 1.8.4 on MacOS X
Tiger
against PostgreSQL 8.1.

Thanks,
H

For me my issue was out of date PostgreSQL drivers.