I just installed Rails for testing on a machine and have been having problems following a tutorial online. The tutorial is at http://wiki.rubyonrails.com/rails/show/Tutorial and I am running this on: Fedora 3 Ruby 1.8.2-1 PostgreSQL 7.4.7-3 ruby-postgres-20050412 The only difference I made while following the tutorial was to use names, but those names were consistently used in all the same places. When I load my test page I get the following error: NoMethodError in Search#home undefined method `find'' for WEBrick::Log:Class app/controllers/search_controller.rb:31:in `home'' script/server:48 In app/controllers/search_controller.rb:31 I have: (30) def home (31) @log = Log.find(1) (32) end I haven''t been able to find anything showing if .find was removed or if the PostgreSQL adapter requires something else. Does anyone know if this is right? If the tutorial is out of date, is there an updated tutorial somewhere? Thanks for any help.
You have named your model class with the same name as used by WEBrick''s Log''ing class. Ruby is trying to figure out which object you are referencing and must find WEBrick::Log before your ActiveRecord class by the same name. Try making line (31): @log = ActiveRecord::Base::Log.find(1) Jon --- "The Supreme Personality of Godhead said: Time I am, the great destroyer of the worlds, and I have come here to destroy all people. With the exception of you, all the soldiers here on both sides will be slain." (Bagavad Gita 11.32)>------------------------------------------ >From: Wayne Pierce <shalofin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >Subject: [Rails] Problems with Rails+Postgres+WebBrick > > NoMethodError in Search#home > > undefined method `find'' for WEBrick::Log:Class > > app/controllers/search_controller.rb:31:in `home'' > script/server:48 > >In app/controllers/search_controller.rb:31 I have: > >(30) def home >(31) @log = Log.find(1) >(32) end >------------------------------------------
Thanks, I don''t know why I hadn''t considered that... I renamed everything and that error is gone...now I just have a PostgreSQL connection error. Is there anything special I need to do for Rails to access the database? Besides having the correct information in the config/database.yml file. The connection information is the same that I am actively useing elsewhere. I can access PostgreSQL with "psql -d seclog_development" and through Apache with mod_python. When I use Rails I get the same generic PostgreSQL error message when unable to connect, ''Is the server running on host "localhost" and accepting TCP/IP connections on port 5432?'' Both of which are ''yes''. Do I need to explicitly call a connection method in one of the files? Wayne On 4/29/05, Jon-Carlos Rivera <imbcmdth-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> You have named your model class with the same name as used by WEBrick''s > Log''ing class. Ruby is trying to figure out which object you are referencing > and must find WEBrick::Log before your ActiveRecord class by the same name. > Try making line (31): > > @log = ActiveRecord::Base::Log.find(1) > > Jon > --- > "The Supreme Personality of Godhead said: Time I am, the great destroyer of > the worlds, and I have come here to destroy all people. With the exception > of you, all the soldiers here on both sides will be slain." > (Bagavad Gita 11.32) > > >------------------------------------------ > >From: Wayne Pierce <shalofin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > >Subject: [Rails] Problems with Rails+Postgres+WebBrick > > > > NoMethodError in Search#home > > > > undefined method `find'' for WEBrick::Log:Class > > > > app/controllers/search_controller.rb:31:in `home'' > > script/server:48 > > > >In app/controllers/search_controller.rb:31 I have: > > > >(30) def home > >(31) @log = Log.find(1) > >(32) end > >------------------------------------------ > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Julian ''Julik'' Tarkhanov
2005-Apr-29 16:58 UTC
Re: Problems with Rails+Postgres+WebBrick
On 28-apr-05, at 21:02, Wayne Pierce wrote:> > In app/controllers/search_controller.rb:31 I have: > > (30) def home > (31) @log = Log.find(1) > (32) end >You have a namespace clash. Rename your model to something else - otherwise it conflicts with WeBRICK logger. -- Julian "Julik" Tarkhanov