# Activerecord, created\_on column

**URL:** <https://www.ruby-forum.com/t/activerecord-created-on-column/91312>\
**Category:** Rails\
**Created:** [April 6, 2007, 5:09pm UTC](https://www.ruby-forum.com/t/activerecord-created-on-column/91312 "2007-04-06T17:09:28Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![aaronsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@aaronsmith](https://www.ruby-forum.com/u/aaronsmith)\
**Post date:** [April 6, 2007, 5:09pm UTC](https://www.ruby-forum.com/t/activerecord-created-on-column/91312/1 "2007-04-06T17:09:28Z")

</div>

hey everyone, having some weird experiences when creating a new record  
with active record…

doesn’t active\_record automagically handle created\_on and updated\_on  
coloumns? I keep getting errors::

ArgumentError: wrong number of arguments (1 for 0)  
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/callbacks.rb:328:in  
`notify' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/callbacks.rb:328:in`callback’  
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/callbacks.rb:295:in  
`valid?' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/validations.rb:751:in`save\_without\_transactions’  
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/transactions.rb:129:in  
`save' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/database_statements.rb:59:in`transaction’  
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/transactions.rb:95:in  
`transaction' /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/transactions.rb:121:in`transaction’  
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/transactions.rb:129:in  
`save' ./test/unit/user_test.rb:46:in`test\_create\_user’

I understand what the error is saying about wrong arguments… but none  
of my methods are using any arguments… Here is the test script i’ve  
written to test i…

require ‘rubygems’  
require ‘active\_record’

class Users \< ActiveRecord::Base  
end

class T  
def initialize  
ActiveRecord::Base.establish\_connection(  
:adapter =\> “mysql”,  
:host =\> “localhost”,  
:username =\> “root”,  
:password =\> “”,  
:database =\> “something\_dev”  
)  
end

def ctest  
@nu = Users.new({  
:user\_name =\> ‘davidh’,  
:first\_name =\> ‘david’,  
:last\_name =\> ‘hasselhoffenmeier’,  
:phone =\> ‘34928293’,  
:email =\> ‘removed\_email\_address@domain.invalid’,  
:company =\> ‘whatever’,  
:user\_type =\> 0,  
:notify =\> 0})  
@nu.save  
end  
end

@r = T.new  
@r.ctest

–my table has a created\_on column as a date type, and I get the above  
errors when running this script…  
any ideas?

thanks all

---

<div class="post-metadata">

**Author:** ![aaronsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@aaronsmith](https://www.ruby-forum.com/u/aaronsmith)\
**Post date:** [April 6, 2007, 5:15pm UTC](https://www.ruby-forum.com/t/activerecord-created-on-column/91312/2 "2007-04-06T17:15:24Z")

</div>

aaronsmith wrote:

> `callback’  
> /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/transactions.rb:121:in
> 
> ```
> :adapter => "mysql",
> :first_name => 'david',
> 
> ```
> 
> @r = T.new  
> @r.ctest
> 
> –my table has a created\_on column as a date type, and I get the above  
> errors when running this script…  
> any ideas?
> 
> thanks all

Not sure if this helps, but I think created\_on needs to be a timestamp  
not a date…  
Cheers  
Mohit.

---

<div class="post-metadata">

**Author:** ![aaronsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@aaronsmith](https://www.ruby-forum.com/u/aaronsmith)\
**Post date:** [April 6, 2007, 5:30pm UTC](https://www.ruby-forum.com/t/activerecord-created-on-column/91312/3 "2007-04-06T17:30:10Z")

</div>

> Not sure if this helps, but I think created\_on needs to be a timestamp  
> not a date…  
> Cheers  
> Mohit.

Shoot - that didn’t seem to help any… it seems like there is actually a  
bigger problem. As I have taken out the created\_on column, and now when  
I run my unit tests I still get that error…

Is there anything that migrations do specifically to a database to be  
active record friendly? As I have not been using migrations… just using  
navicat and hacking away.

---

<div class="post-metadata">

**Author:** ![aaronsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@aaronsmith](https://www.ruby-forum.com/u/aaronsmith)\
**Post date:** [April 6, 2007, 5:50pm UTC](https://www.ruby-forum.com/t/activerecord-created-on-column/91312/4 "2007-04-06T17:50:22Z")

</div>

Mohit S. wrote:

> aaronsmith wrote:
> 
> > Is there anything that migrations do specifically to a database to be  
> > active record friendly? As I have not been using migrations… just using  
> > navicat and hacking away.
> 
> I think the only main difference is that they will by default create an  
> auto-increment field called ‘id’ that serves as the primary key.  
> Are you creating one?
> 
> Cheers  
> Mohit.

yes… and actually… the only time this is happening is when i’ve got a  
created\_on column in the database. I’ve tried numerous different data  
types (date, datetime, timestamp)… when using ActiveRecord by itself it  
didn’t matter… but now when tying it through rails… it just fails all  
together…

---

<div class="post-metadata">

**Author:** ![aaronsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@aaronsmith](https://www.ruby-forum.com/u/aaronsmith)\
**Post date:** [April 6, 2007, 5:34pm UTC](https://www.ruby-forum.com/t/activerecord-created-on-column/91312/5 "2007-04-06T17:34:15Z")

</div>

aaronsmith wrote:

> Is there anything that migrations do specifically to a database to be  
> active record friendly? As I have not been using migrations… just using  
> navicat and hacking away.

I think the only main difference is that they will by default create an  
auto-increment field called ‘id’ that serves as the primary key.  
Are you creating one?

Cheers  
Mohit.

---

<div class="post-metadata">

**Author:** ![aaronsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@aaronsmith](https://www.ruby-forum.com/u/aaronsmith)\
**Post date:** [April 6, 2007, 6:24pm UTC](https://www.ruby-forum.com/t/activerecord-created-on-column/91312/6 "2007-04-06T18:24:20Z")

</div>

Mohit S. wrote:

> aaronsmith wrote:
> 
> > > I think the only main difference is that they will by default create an  
> > > didn’t matter… but now when tying it through rails… it just fails all  
> > > together…
> 
> sorry, I’m at wits’ ends here - haven’t experienced this issue at all.  
> I do hope that someone else replies to the thread :-S
> 
> Cheers  
> Mohit.

AHH… I got it… one of my colum names was ‘notify’, and apparently  
active\_record doesn’t like that. there must be a notify method on  
active\_record.

-A

---

<div class="post-metadata">

**Author:** ![aaronsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@aaronsmith](https://www.ruby-forum.com/u/aaronsmith)\
**Post date:** [April 6, 2007, 6:08pm UTC](https://www.ruby-forum.com/t/activerecord-created-on-column/91312/7 "2007-04-06T18:08:34Z")

</div>

aaronsmith wrote:

> > I think the only main difference is that they will by default create an  
> > didn’t matter… but now when tying it through rails… it just fails all  
> > together…

sorry, I’m at wits’ ends here - haven’t experienced this issue at all.  
I do hope that someone else replies to the thread :-S

Cheers  
Mohit.

---

<div class="post-metadata">

**Author:** ![aaronsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@aaronsmith](https://www.ruby-forum.com/u/aaronsmith)\
**Post date:** [April 6, 2007, 6:29pm UTC](https://www.ruby-forum.com/t/activerecord-created-on-column/91312/8 "2007-04-06T18:29:35Z")

</div>

aaronsmith wrote:

> > >
> 
> -A

Good to know that, phew!  
Cheers  
Mohit.

---

<div class="post-metadata">

**Author:** ![aaronsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@aaronsmith](https://www.ruby-forum.com/u/aaronsmith)\
**Post date:** [April 6, 2007, 6:27pm UTC](https://www.ruby-forum.com/t/activerecord-created-on-column/91312/9 "2007-04-06T18:27:35Z")

</div>

On 6-Apr-07, at 12:07 PM, Mohit S. wrote:

> > > > navicat and hacking away.
> 
> sorry, I’m at wits’ ends here - haven’t experienced this issue at all.  
> I do hope that someone else replies to the thread :-S
> 
> Cheers  
> Mohit.

This feels like a red-herring.

try to create a simple project that replicates the problem.

I suspect that in your current project something else is triggering  
this happen - a plugin, a callback.

Cheers,  
Jodi  
General Partner  
The nNovation Group inc.  
www.nnovation.ca/blog

---

<div class="post-metadata">

**Author:** ![aaronsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@aaronsmith](https://www.ruby-forum.com/u/aaronsmith)\
**Post date:** [April 6, 2007, 8:06pm UTC](https://www.ruby-forum.com/t/activerecord-created-on-column/91312/10 "2007-04-06T20:06:37Z")

</div>

aaronsmith wrote:

> Mohit S. wrote:
> 
> > aaronsmith wrote:
> > 
> > > > I think the only main difference is that they will by default create an  
> > > > didn’t matter… but now when tying it through rails… it just fails all  
> > > > together…
> > 
> > sorry, I’m at wits’ ends here - haven’t experienced this issue at all.  
> > I do hope that someone else replies to the thread :-S
> > 
> > Cheers  
> > Mohit.
> 
> AHH… I got it… one of my colum names was ‘notify’, and apparently  
> active\_record doesn’t like that. there must be a notify method on  
> active\_record.
> 
> -A

Is there a comprehensive list of column names that one should avoid  
unless they are using the build-in functionality eg “created\_on/at”  
“updated\_on/at” etc…

JFM

---

<div class="post-metadata">

**Author:** ![aaronsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@aaronsmith](https://www.ruby-forum.com/u/aaronsmith)\
**Post date:** [April 6, 2007, 11:00pm UTC](https://www.ruby-forum.com/t/activerecord-created-on-column/91312/11 "2007-04-06T23:00:55Z")

</div>

Not that i’m aware of.
