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: <location> <updated-at></updated-at> <id type="integer">7632</id> <created-at></created-at> ... Snip other stuff ... </location> 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
** This is a repost. After playing with this for a much longer amount of time I am still baffled and I didn''t get any replies. Any help is VERY much appreciated. ** 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: <location> <updated-at></updated-at> <id type="integer">7632</id> <created-at></created-at> ... Snip other stuff ... </location> 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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Levent Ali
2006-Oct-02 14:58 UTC
Re: created_at Exists In DB But AR Object created_at is nil?
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: > > <location> > <updated-at></updated-at> > <id type="integer">7632</id> > <created-at></created-at> > ... Snip other stuff ... > </location> > > 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-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
For me my issue was out of date PostgreSQL drivers.> From: Levent Ali <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > Reply-To: <rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > Date: Mon, 2 Oct 2006 16:58:38 +0200 > To: <rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > Subject: [Rails] Re: created_at Exists In DB But AR Object created_at is nil? > > > 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: >> >> <location> >> <updated-at></updated-at> >> <id type="integer">7632</id> >> <created-at></created-at> >> ... Snip other stuff ... >> </location> >> >> 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 > > > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---