Running on XP, Rails v1.1.6, Ruby 1.8.4, mysql 5.0.24, WEBrick 1.3.1 just doing a basic ''scaffold'' against a table in mysql, I originally got the "undefined method ''each''" error at all times then saw something advising to uninstall the gem mysql package, which I did. then it seemed to work! - but only the first ''list'' call to the website returns the data from the table - reloading the identical page thereafter generates this error, so it is not at all stable. Restarting WEBrick again works first call only Any advice appreciated [2006-08-13 14:00:19] INFO WEBrick 1.3.1 [2006-08-13 14:00:19] INFO ruby 1.8.4 (2006-04-14) [i386-mswin32] [2006-08-13 14:00:19] INFO WEBrick::HTTPServer#start: pid=4040 port=3000 127.0.0.1 - - [13/Aug/2006:14:00:41 Eastern Daylight Time] "GET /hello/list HTTP/1.1" 200 1865- -> /hello/list 127.0.0.1 - - [13/Aug/2006:14:00:44 Eastern Daylight Time] "GET /hello/list HTTP/1.1" 500 8842- -> /hello/list trace from the web page c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/connection_adapters/mysql_adapter.rb:292:in `columns'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/base.rb:696:in `columns'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/calculations.rb:216:in `column_for'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/calculations.rb:138:in `calculate'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active_record/calculations.rb:66:in `count'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/pagination.rb:172:in `count_collection_for_pagination'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/pagination.rb:196:in `paginator_and_collection_for'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/pagination.rb:129:in `paginate'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/scaffolding.rb:109:in `list'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in `perform_action_without_filters'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:368:in `perform_action_without_benchmark'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/rescue.rb:82:in `perform_action'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:in `process_without_filters'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:377:in `process_without_session_management_support'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/session_management.rb:117:in `process'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:in `dispatch'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:115:in `handle_dispatch'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:81:in `service'' c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'' c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'' c:/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'' c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'' c:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'' c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'' c:/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'' c:/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:67:in `dispatch'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/servers/webrick.rb:59 c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/server.rb:30 c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'' script/server:3 -- Posted via http://www.ruby-forum.com/.
I''m having EXACTLY the same problem however I''m running Apache 2. The first call works however if I refresh the page, it no longer works (or any other call to the database) and I get: undefined method `each'' for #<Mysql:0x342fca4> I also run MSSQL server on this machine and if I point the database.yml to that instead (took a lot of setting up but finally got it working), it works perfectly. Which is odd... Any help greatly appreciated. Nick -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Nick wrote:> I''m having EXACTLY the same problem however I''m running Apache 2. The > first call works however if I refresh the page, it no longer works (or > any other call to the database) and I get: > > undefined method `each'' for #<Mysql:0x342fca4> > > I also run MSSQL server on this machine and if I point the database.yml > to that instead (took a lot of setting up but finally got it working), > it works perfectly. Which is odd... > > Any help greatly appreciated. > > NickI had this exact problem on a development based windows machine. The problem was my libmysql.dll was not in sync with the MySQL server that i had running. (I used instantrails for the mysql server and just downloaded the 5.0 release dll from MySQL.com) So i suggest if you have upgraded your MySQL install make sure that you have the mysql gem re compiled so that it is linked with the same mysql libraries. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi and thanks for the very fast reply! The funny thing is that I have only ever used MySQL v.5.0. I did however use InstantRails at one point just to see what it was like. I didn''t like it, uninstalled it and reinstalled MySQL v.5.0. Another odd thing is that I was having problems making Rails work at all with the DB... I read somewhere that all I needed to do was copy the libmySQL.dll file to my Windows\System32 directory. Which I did. Worked. However, then I started experiencing these problems described above! Finally, sorry to sound like a fool, but what exactly do you mean by "have the mysql gem re compiled" and how would I go about doing that? With thanks again Nick -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ok sorry i thought you were on a *nix type platform where the gem''s are linked against your library''s. If you are on windows then just make sure that you are using the proper libmysql.dll from your distribution. Normally it is located in the bin directory of your mysql install. Also i actually perfer to put the libmysql.dll in the directory where the ruby.exe is located. that way i don''t have stuff cluttering up the Windows system dir. Also scan your harddrive and see if there is more instances of libmysql.dll that you might not know about that ruby is picking up. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks for the reply but that wasn''t the problem in the end. I have successfully found what the problem was! Having rumaged around on the web for days, I came across someone suggesting that I install a different mysql.so in the "C:\ruby\lib\ruby\site_ruby\1.8\i386-msvcrt" folder. I did. Nothing changed. While trying the two different files, I was constantly changing the names to mysql.so_old or something like that. At one point BOTH were named _old and _new... i.e. Ruby couldn''t find a SINGLE mysql.so. And would you believe this actually worked! It was the mysql.so file that was causing problems... Simply removing the file made it all work again! Very odd indeed! Thanks for your help all the same! Nick -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Just to add to my last post... The major problem is that there does not appear to be ONE SINGLE installation tutorial for Ruby/Apache/MySQL on Windows XP that actually works. Everyone I spoke to has had to use a strange mix of numerous different tutorials to finally get it working. Naturally, I tried numerous different things to finally get mine working and probaby one of them involved installing this stupid mysql.so file. Anyway, fingers crossed, no more problems... Nick -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Nick, I think when you deleted the mysql.so file you actually put the mysql gem into ruby only mode. So you will have alot slower times doing stuff with the database. instead of using a native module. (Though i am not 100% sure on this though) And i know your pain. I currently have 3 seperate environments (Linux, Windows, MacOSX) that i do development in and Windows one has been the hardest to setup. Rob Schultz Nick wrote:> Just to add to my last post... > > The major problem is that there does not appear to be ONE SINGLE > installation tutorial for Ruby/Apache/MySQL on Windows XP that actually > works. Everyone I spoke to has had to use a strange mix of numerous > different tutorials to finally get it working. > > Naturally, I tried numerous different things to finally get mine working > and probaby one of them involved installing this stupid mysql.so file. > > Anyway, fingers crossed, no more problems... > > > Nick > > -- > Posted via http://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I suggest that you should confirm the version of your MySQL is NOT 5.0.24. In my environment, MySQL 5.0.22 and MySQL 5.0.24a work fine, but the 5.0.24 does not. The latest version was released 10 days ago... It is quite possible that you have got the bad one unfortunately like my colleague. sharky wrote:> > I had similar problems as have been mentioned...The first operation after > starting WEBrick or Mongrel or whatever server I was using would work > fine, but the next would throw the undefined method ''each'' on #<Mysql > error. > > I think the cause was a version mismatch between the ruby bindings for > mysql and the version of mysql server I had installed. I tried and failed > to get everything working with MySQL Server 5.0. Today I tried the > Instant Rails package, which includes MySQL 4.1.something, and it has > worked fine. > > To anyone involved with Ruby/Rails/MySQL development, this is a pretty big > issue. Keep us all updated if anyone gets things working like they should > be... >-- View this message in context: http://www.nabble.com/undefined-method-%60each%27-for--%3CMysql%3A0x3874b20%3E-tf2099958.html#a6133190 Sent from the RubyOnRails Users forum at Nabble.com. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Schultz wrote:> Nick, > I think when you deleted the mysql.so file you actually put the mysql > gem into ruby only mode. So you will have alot slower times doing stuff > with the database. instead of using a native module. (Though i am not > 100% sure on this though) And i know your pain. I currently have 3 > seperate environments (Linux, Windows, MacOSX) that i do development in > and Windows one has been the hardest to setup. > > Rob Schultzhey man, before i used to use the instant rails because it was so easy, but recently i just installed MySQL v.5.0. with ruby 1.8 and i get this error. and i am using webrick do you know what i need to do to make this work ? i would appreciate it if you could help me thank you -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
jeanpierre@gmail.com
2006-Nov-04 02:12 UTC
[Rails] undefined method `each'' for #<Mysql:0x3874b20>
On 8/13/06, Paul <ringspa@aol.com> wrote:> Running on XP, Rails v1.1.6, Ruby 1.8.4, mysql 5.0.24, WEBrick 1.3.1 > > just doing a basic ''scaffold'' against a table in mysql, I originally got > the "undefined method ''each''" error at all times then saw something > advising to uninstall the gem mysql package, which I did. > > then it seemed to work! - but only the first ''list'' call to the website > returns the data from the table - reloading the identical page > thereafter generates this error, so it is not at all stable. Restarting > WEBrick again works first call only > > Any advice appreciatedstrange, i remember seeing a similar error after upgrading my mysql install from 5.0.22 to 5.0.24 via macports. NoMethodError (undefined method `each'' for #<Mysql:0x2703e0c>): /vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adap ter.rb:292:in `columns'' the way i worked around it was to uninstall/clean/reinstall my ruby mysql bindings. check my previous post to the list ''mysql5 5.0.24 upgrade note for macports users'' for more details: <http://rubyurl.com/aY0> (abbreviated big giant google groups link) maybe a similar workaround will work for you too? regards, jean-pierre
Hi Nick, I had the same problem - and you helped me very much! Renaming mysql.so solves all , now Rails works fine. Thank you thomas -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
FYI: This problem can be caused by an a mismatch between versions of the mySQL gem and the version of mySQL. If you are using version 2.7.3 of the mySQL driver, make sure you upgrade your mySQL installation to 5.0.27 from 5.0.24 - that can fix the problem (worked for me...) - John Thomas Walter wrote:> Hi Nick, > > I had the same problem - and you helped me very much! Renaming mysql.so > solves all , now Rails works fine. > > Thank you > > > thomas-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
This error drives me crazy! For the last 3 hours I was trying to unsuccessfully find out what is wrong with my script, I have pinpointed it to this: I am running two SELECT queries like this: require ''mysql'' dbh = Mysql.connect("localhost", "aaa", "aaa", "aaa") #Query 1 res = dbh.query("SELECT id FROM logs WHERE id=''10''"); puts "Number of rows returned: #{res.num_rows}" res.free #Query 2 res = dbh.query("SELECT id FROM logs WHERE id=''10''"); puts "Number of rows returned: #{res.num_rows}" res.free And here is what I''m getting: For the first query everything is ok: Number of rows returned:0 For the 2nd: undefined method ''num_rows'' for #<Mysql:0x34eaaa18> (NoMethodError) For some reason the second query does not return an object of class Mysql::Result and I have no idea why. I even tried to dbh.close and reopen - it does not help! The INSERTS are working fine, I tried several insert statements, and they work without a glitch. My set-up: OS: Windows VISTA MySQL GEM: 2.7.3 MySQL: 5.1.22 Ruby: 1.8.6 Your help will be extremely appreciated! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Vlad Vlad wrote:> For some reason the second query does not return an object of class > Mysql::Result and I have no idea why. I even tried to dbh.close and > reopen - it does not help! The INSERTS are working fine, I tried several > insert statements, and they work without a glitch.I''ve managed to go around it, although I do not understand what caused an issue. Any way, when I use the block notation, it works fine: dbh.query("SELECT id FROM logs WHERE id=''10''") { |res| puts "Number of rows returned: #{res.num_rows}" } Hope it helps someone, and if you can explain what causes that behaviour, will be very good. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---