Curtis Spencer
2006-Sep-12 01:20 UTC
Help with Transient Error involving constructor on ActiveRecord::Base
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Zed Shaw
2006-Sep-12 02:36 UTC
Re: Help with Transient Error involving constructor on ActiveRecord::Base
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 http://www.zedshaw.com/ http://mongrel.rubyforge.org/ http://www.lingr.com/room/3yXhqKbfPy8 -- Come get help. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Curtis Spencer
2006-Sep-12 05:06 UTC
Re: Help with Transient Error involving constructor on ActiveRecord::Base
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 Zed Shaw wrote:> 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. > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
zdennis
2006-Sep-12 17:26 UTC
Re: Help with Transient Error involving constructor on ActiveRecord::Base
-----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 iD8DBQFFBu3gMyx0fW1d8G0RAmsBAJ42EP95ryrRg1/kLFinU3X2iETdIwCggZOg OAl9vDaNkkVo0bmllr3Kbw0=p5Fo -----END PGP SIGNATURE----- --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Curtis Spencer
2006-Sep-12 17:34 UTC
Re: Help with Transient Error involving constructor on ActiveRecord::Base
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... > > -CurtisAfter 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> > Zed Shaw wrote: >> 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. >> >> > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Curtis Spencer
2006-Sep-12 17:58 UTC
Re: Help with Transient Error involving constructor on ActiveRecord::Base
> > 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> Zach > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.2.2 (GNU/Linux) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iD8DBQFFBu3gMyx0fW1d8G0RAmsBAJ42EP95ryrRg1/kLFinU3X2iETdIwCggZOg > OAl9vDaNkkVo0bmllr3Kbw0> =p5Fo > -----END PGP SIGNATURE----- > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Zed Shaw
2006-Sep-13 00:03 UTC
Re: Help with Transient Error involving constructor on ActiveRecord::Base
On Tue, 2006-09-12 at 10:34 -0700, Curtis Spencer wrote:> 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... > > > > -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.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 http://www.zedshaw.com/ http://mongrel.rubyforge.org/ http://www.lingr.com/room/3yXhqKbfPy8 -- Come get help. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---