# RoR problems with Created\_At and PostgreSQL

**URL:** <https://www.ruby-forum.com/t/ror-problems-with-created-at-and-postgresql/55111>\
**Category:** Rails\
**Created:** [March 17, 2006, 1:43am UTC](https://www.ruby-forum.com/t/ror-problems-with-created-at-and-postgresql/55111 "2006-03-17T01:43:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![khaja](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/5f9b8f/32.png) [@khaja](https://www.ruby-forum.com/u/khaja)\
**Post date:** [March 17, 2006, 1:43am UTC](https://www.ruby-forum.com/t/ror-problems-with-created-at-and-postgresql/55111/1 "2006-03-17T01:43:03Z")

</div>

So, I wrote some pages which essentially created some articles which are  
saved to a database, which also include both the “magic” rows  
‘created\_at’ and ‘updated\_at’.

Now, on my development machine I’m running the MySQL-database and  
everything worked as I wanted it to. On the live server I’ve had to  
switch to PostgreSQL 8.1 due to some horrendous dependencies.

Now, the weird thing is that everything works fine - save for the  
‘created\_at’-timestamp. The ‘updated\_at’-timestamp is indeed updated as  
it should. Both are created by the exact same SQL statement and differ  
only by name.

Ruby is Version 1.8.4, Rails is at 1.0.0

Any pointers as to what I might be doing wrong? I could of course set  
the timestamp myself…

---

<div class="post-metadata">

**Author:** ![khaja](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/5f9b8f/32.png) [@khaja](https://www.ruby-forum.com/u/khaja)\
**Post date:** [March 17, 2006, 3:05am UTC](https://www.ruby-forum.com/t/ror-problems-with-created-at-and-postgresql/55111/2 "2006-03-17T03:05:11Z")

</div>

On Fri, 2006-03-17 at 01:43 +0100, Johannes H. wrote:

> it should. Both are created by the exact same SQL statement and differ  
> only by name.
> 
> Ruby is Version 1.8.4, Rails is at 1.0.0
> 
> Any pointers as to what I might be doing wrong? I could of course set  
> the timestamp myself…

* * *

see if created\_on works for you.

Craig

---

<div class="post-metadata">

**Author:** ![khaja](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/5f9b8f/32.png) [@khaja](https://www.ruby-forum.com/u/khaja)\
**Post date:** [March 17, 2006, 12:08pm UTC](https://www.ruby-forum.com/t/ror-problems-with-created-at-and-postgresql/55111/3 "2006-03-17T12:08:24Z")

</div>

Craig W. wrote:

> On Fri, 2006-03-17 at 01:43 +0100, Johannes H. wrote:
> 
> > it should. Both are created by the exact same SQL statement and differ  
> > only by name.
> > 
> > Ruby is Version 1.8.4, Rails is at 1.0.0
> > 
> > Any pointers as to what I might be doing wrong? I could of course set  
> > the timestamp myself…
> 
> * * *
> 
> see if created\_on works for you.
> 
> Craig

I just found the error myself. You may not set a default value for the  
timestamp column ‘created\_at’ - if there’s a default value it will  
_always_ be used.

---

<div class="post-metadata">

**Author:** ![khaja](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/5f9b8f/32.png) [@khaja](https://www.ruby-forum.com/u/khaja)\
**Post date:** [March 17, 2006, 12:19pm UTC](https://www.ruby-forum.com/t/ror-problems-with-created-at-and-postgresql/55111/4 "2006-03-17T12:19:02Z")

</div>

Johannes H. wrote:

> > see if created\_on works for you.
> > 
> > Craig
> 
> I just found the error myself. You may not set a default value for the  
> timestamp column ‘created\_at’ - if there’s a default value it will  
> _always_ be used.

I had this problem too. [http://dev.rubyonrails.org/ticket/2257](http://dev.rubyonrails.org/ticket/2257)

Jeroen
