Activerecord, created_on column

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:incallback’
/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:insave_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:intransaction’
/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:intransaction’
/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:intest_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 => ‘[email protected]’,
: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

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.

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.

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…

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.

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

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.

aaronsmith wrote:

-A

Good to know that, phew!
Cheers
Mohit.

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

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

Not that i’m aware of.