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
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.
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?
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..
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
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.