Forum: Ruby on Rails ArgumentError on model create statement

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Cf8a610127d1108dfe67f673320b5fe5?d=identicon&s=25 Craig Jolicoeur (craigpj)
on 2009-02-21 01:08
I have a rails app model that I'm getting a strange error that is just
baffling me.  I've stripped everything out of my model down to the
basics and still get the error.

So, here is the current model:


class Metric < ActiveRecord::Base
end


When I go into the console, and issue a simple "Metric.create" command I
get the following error:

>> Metric.create
ArgumentError: wrong number of arguments (1 for 0)
  from
/src/parkassist/paseweb/vendor/rails/activerecord/lib/active_record/callbacks.rb:288:in
`callback'
  from
/src/parkassist/paseweb/vendor/rails/activerecord/lib/active_record/callbacks.rb:288:in
`valid?'
  from
/src/parkassist/paseweb/vendor/rails/activerecord/lib/active_record/validations.rb:1008:in
`save_without_dirty'
  from
/src/parkassist/paseweb/vendor/rails/activerecord/lib/active_record/dirty.rb:79:in
`save_without_transactions'
  from
/src/parkassist/paseweb/vendor/rails/activerecord/lib/active_record/transactions.rb:179:in
`send'
  from
/src/parkassist/paseweb/vendor/rails/activerecord/lib/active_record/transactions.rb:179:in
`with_transaction_returning_status'
  from
/src/parkassist/paseweb/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:66:in
`transaction'
  from
/src/parkassist/paseweb/vendor/rails/activerecord/lib/active_record/transactions.rb:129:in
`transaction'
  from
/src/parkassist/paseweb/vendor/rails/activerecord/lib/active_record/transactions.rb:138:in
`transaction'
  from
/src/parkassist/paseweb/vendor/rails/activerecord/lib/active_record/transactions.rb:178:in
`with_transaction_returning_status'
  from
/src/parkassist/paseweb/vendor/rails/activerecord/lib/active_record/transactions.rb:146:in
`save'
  from
/src/parkassist/paseweb/vendor/rails/activerecord/lib/active_record/transactions.rb:158:in
`rollback_active_record_state!'
  from
/src/parkassist/paseweb/vendor/rails/activerecord/lib/active_record/transactions.rb:146:in
`save'
  from
/src/parkassist/paseweb/vendor/rails/activerecord/lib/active_record/base.rb:693:in
`create'
  from (irb):12


Any help?  What am I missing and why does a simple create statement
through this ArgumentError?
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-02-21 09:52
(Received via mailing list)
On 21 Feb 2009, at 00:08, Craig Jolicoeur wrote:

>
> I have a rails app model that I'm getting a strange error that is just
> baffling me.  I've stripped everything out of my model down to the
> basics and still get the error.
>
> So, here is the current model:
>
>
> class Metric < ActiveRecord::Base
> end
Any plugins in that app that are extending activerecord ?

Fred
Cf8a610127d1108dfe67f673320b5fe5?d=identicon&s=25 Craig Jolicoeur (craigpj)
on 2009-02-21 15:03
Thanks, but the plugins aren't an issue.  I found the problem.

I should have included my model attributes as well from the DB.

I had a DB column called "callback" which interfered with built-in AR
functionality.

Frederick Cheung wrote:
> On 21 Feb 2009, at 00:08, Craig Jolicoeur wrote:
>
>>
>> I have a rails app model that I'm getting a strange error that is just
>> baffling me.  I've stripped everything out of my model down to the
>> basics and still get the error.
>>
>> So, here is the current model:
>>
>>
>> class Metric < ActiveRecord::Base
>> end
> Any plugins in that app that are extending activerecord ?
>
> Fred
This topic is locked and can not be replied to.