# Help with Transient Error involving constructor on ActiveRec

**URL:** <https://www.ruby-forum.com/t/help-with-transient-error-involving-constructor-on-activerec/68368>\
**Category:** Rails\
**Created:** [September 12, 2006, 3:25am UTC](https://www.ruby-forum.com/t/help-with-transient-error-involving-constructor-on-activerec/68368 "2006-09-12T03:25:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Curtis\_Spencer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e495f1/32.png) [@Curtis\_Spencer](https://www.ruby-forum.com/u/Curtis_Spencer)\
**Post date:** [September 12, 2006, 3:25am UTC](https://www.ruby-forum.com/t/help-with-transient-error-involving-constructor-on-activerec/68368/1 "2006-09-12T03:25:33Z")

</div>

Hi,

I am encountering a strange problem where I am getting an exception in  
one of my controllers where the line is essentially:

@model = Model.new(params[:model])

I get the following exception:

A ArgumentError occurred in model#model\_create:

wrong number of arguments (1 for 0)  
[RAILS\_ROOT]/app/controllers/model\_controller.rb:80:in `initialize’

which is pretty strange because it only occurs sometimes, and I cannot  
reproduce it in development, just production.

I use an Apache 2.2.2 system with a pack of mongrels behind it.

ruby 1.8.4 (2005-12-24) [x86\_64-linux]

These are the versions of my gems:  
mongrel (0.3.13.3)  
activerecord (1.14.4, 1.14.3)  
rails (1.1.6, 1.1.5, 1.1.4)  
actionpack (1.12.5, 1.12.4, 1.12.3)  
activesupport (1.3.1)

I have tried it on my development machine (OS X) with Mongrel, but I  
cannot get it to reproduce. Just on my production machine ☹

Any ideas?

Thanks,  
Curtis

---

<div class="post-metadata">

**Author:** ![Curtis\_Spencer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e495f1/32.png) [@Curtis\_Spencer](https://www.ruby-forum.com/u/Curtis_Spencer)\
**Post date:** [September 12, 2006, 4:41am UTC](https://www.ruby-forum.com/t/help-with-transient-error-involving-constructor-on-activerec/68368/2 "2006-09-12T04:41:45Z")

</div>

On Mon, 2006-09-11 at 18:20 -0700, Curtis Spencer wrote:

> Hi,
> 
> I am encountering a strange problem where I am getting an exception in  
> one of my controllers where the line is essentially:
> 
> @model = Model.new(params[:model])
> 
> I get the following exception:

Most likely you can’t have a Model named Model since that’s what Model  
is already named: Model.

–  
Zed A. Shaw

> **[Zed A. shaw](https://zedshaw.com/)**
>
> Personal essays and writings by Zed A. Shaw.

[http://mongrel.rubyforge.org/](http://mongrel.rubyforge.org/)  
[http://www.lingr.com/room/3yXhqKbfPy8](http://www.lingr.com/room/3yXhqKbfPy8) – Come get help.

---

<div class="post-metadata">

**Author:** ![Curtis\_Spencer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e495f1/32.png) [@Curtis\_Spencer](https://www.ruby-forum.com/u/Curtis_Spencer)\
**Post date:** [September 12, 2006, 7:14am UTC](https://www.ruby-forum.com/t/help-with-transient-error-involving-constructor-on-activerec/68368/3 "2006-09-12T07:14:01Z")

</div>

Zed,

Haha, sorry I should have been more specific. That is not the real model  
name. I was just making the question more generic, which inevitably  
caused confusion. My bad…

@widget = Widget.new(params[:widget])

I only get the exception periodically…

-Curtis

---

<div class="post-metadata">

**Author:** ![Curtis\_Spencer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e495f1/32.png) [@Curtis\_Spencer](https://www.ruby-forum.com/u/Curtis_Spencer)\
**Post date:** [September 12, 2006, 7:23pm UTC](https://www.ruby-forum.com/t/help-with-transient-error-involving-constructor-on-activerec/68368/4 "2006-09-12T19:23:32Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Curtis Spencer wrote:

> Zed,
> 
> Haha, sorry I should have been more specific. That is not the real model  
> name. I was just making the question more generic, which inevitably  
> caused confusion. My bad…
> 
> @widget = Widget.new(params[:widget])
> 
> I only get the exception periodically…

Try to forcefully load your models in your environment.rb or in your  
controller. I believe Rails will load them as needed, and  
sometimes your controller code will call a model before it’s been  
required.

Zach  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.2.2 (GNU/Linux)  
Comment: Using GnuPG with Mozilla - [http://enigmail.mozdev.org](http://enigmail.mozdev.org)

iD8DBQFFBu3gMyx0fW1d8G0RAmsBAJ42EP95ryrRg1/kLFinU3X2iETdIwCggZOg  
OAl9vDaNkkVo0bmllr3Kbw0=  
=p5Fo  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![Curtis\_Spencer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e495f1/32.png) [@Curtis\_Spencer](https://www.ruby-forum.com/u/Curtis_Spencer)\
**Post date:** [September 12, 2006, 7:47pm UTC](https://www.ruby-forum.com/t/help-with-transient-error-involving-constructor-on-activerec/68368/5 "2006-09-12T19:47:35Z")

</div>

Curtis Spencer wrote:

> -Curtis  
> After doing some more late night testing, I wanted to add a few other  
> things I noticed with the problem.

After a fresh restart of the mongrel processes, I cannot reproduce the  
constructor problem. I did this late last night, and I thought  
everything was good, but in the morning I can continue to get the  
exceptions, so it is something that is occurring over a period of a few  
hours (probably of little or no activity on the site)? Could it have to  
do with the database?

I have ActiveRecord::Base.verification\_timeout = 14400, and I don’t  
notice any Mysql Connection gone away errors.

A ArgumentError occurred in prime#prime\_create:

wrong number of arguments (1 for 0)  
[RAILS\_ROOT]/app/controllers/prime\_controller.rb:80:in `initialize’

which is pretty strange because it only occurs sometimes, and I cannot  
reproduce it in development, just production.

I will repost my environment here:

I use an Apache 2.2.2 system with a pack of mongrels behind it.

ruby 1.8.4 (2005-12-24) [x86\_64-linux]

These are the versions of my gems:  
mongrel (0.3.13.3)  
activerecord (1.14.4, 1.14.3)  
rails (1.1.6, 1.1.5, 1.1.4)  
actionpack (1.12.5, 1.12.4, 1.12.3)  
activesupport (1.3.1)

Is there some way I can find out what could be causing it.  
As for my model it is called Prime. The only other thing I can imagine  
is that something in the ruby world collides with it so that it would  
have a no argument constructor?

Thanks in advance for any help.

-Curtis

---

<div class="post-metadata">

**Author:** ![Curtis\_Spencer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e495f1/32.png) [@Curtis\_Spencer](https://www.ruby-forum.com/u/Curtis_Spencer)\
**Post date:** [September 13, 2006, 2:08am UTC](https://www.ruby-forum.com/t/help-with-transient-error-involving-constructor-on-activerec/68368/6 "2006-09-13T02:08:18Z")

</div>

On Tue, 2006-09-12 at 10:34 -0700, Curtis Spencer wrote:

> > 
> 
> do with the database?
> 
> I have ActiveRecord::Base.verification\_timeout = 14400, and I don’t  
> notice any Mysql Connection gone away errors.

Oh, are you using the MySQL driver that came with Rails or the compiled  
gem? The driver that comes with rails has this problem when talking to  
a MySQL 5.x database.

–  
Zed A. Shaw

> **[Zed A. shaw](https://zedshaw.com/)**
>
> Personal essays and writings by Zed A. Shaw.

[http://mongrel.rubyforge.org/](http://mongrel.rubyforge.org/)  
[http://www.lingr.com/room/3yXhqKbfPy8](http://www.lingr.com/room/3yXhqKbfPy8) – Come get help.

---

<div class="post-metadata">

**Author:** ![Curtis\_Spencer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e495f1/32.png) [@Curtis\_Spencer](https://www.ruby-forum.com/u/Curtis_Spencer)\
**Post date:** [September 12, 2006, 8:07pm UTC](https://www.ruby-forum.com/t/help-with-transient-error-involving-constructor-on-activerec/68368/7 "2006-09-12T20:07:37Z")

</div>

> Try to forcefully load your models in your environment.rb or in your controller. I believe Rails will load them as needed, and  
> sometimes your controller code will call a model before it’s been required.

Zach,

In my ApplicationController, I have a model call with all of the models  
I use in my sessions, including this model.

model :prime

Does the order matter in this call because I have :prime toward the end.

Although it seems as though the model is required because ruby knows  
about the symbol Prime, but it just throws the argument error on the  
constructor.

-Curtis
