Forum: Ruby on Rails db:migrate and Mysql error

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.
(Guest)
on 2009-02-09 12:48
(Received via mailing list)
Hi,
Am getting the error "undefined method `each' for #<Mysql:0x483f2d0>"
when I try to run a "rake db:migrate" on a very simple example for a
Mysql database. This follows a very basic setup procedure that works
with sqlite3, but fails when I try to use Mysql (note that I have
verified that the db on mysql is created and accessible to rails)

>rails photos
>cd photos
>ruby script/generate scaffold photo filename:string thumbnail:string description:string
>rake db:migrate
at this point I get an error (see below). Note that the
schema_migrations table is created and if I run the rake command then
the table photos is also created (but I get a command out of sequence
error from rails).

I have read relevant posts regarding versions of mysql and
libmysql.dll which I have taken action on.
I would appreciate any clues as it is driving me nuts %).

I am using:
        MS Windows XP Home Ediition Version 2002 SP3
  ruby ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32]
  rails 2.2.2
  mysql gem 2.7.3
  Mysql 5.1.31-community

Cheers
Barry

The trace is as follows:
C:\rails\photos>C:\rails\photos>rake db:migrate --trace
(in C:/rails/photos)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
rake aborted!
undefined method `each' for #<Mysql:0x483f2d0>
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
connection_adapters/mysql_adapter.rb:414:in `tables'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
connection_adapters/abstract/schema_statements.rb:330:in
`initialize_schema_migrations_table'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
migration.rb:430:in `initialize'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
migration.rb:394:in `new'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
migration.rb:394:in `up'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/
migration.rb:377:in `migrate'
C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/tasks/databases.rake:
111
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `call'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `execute'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `each'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `execute'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:578:in
`invoke_with_call_chain'
C:/Ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:in
`invoke_with_call_chain'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:564:in `invoke'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2019:in
`invoke_task'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in
`top_level'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `each'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in
`top_level'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in
`standard_exception_handling'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1991:in
`top_level'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1970:in `run'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in
`standard_exception_handling'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1967:in `run'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/bin/rake:31
C:/Ruby/bin/rake:19:in `load'
C:/Ruby/bin/rake:19
Frederick C. (Guest)
on 2009-02-09 12:51
(Received via mailing list)
On Feb 9, 10:11 am, "removed_email_address@domain.invalid" 
<removed_email_address@domain.invalid>
wrote:
>
I recall vaguely seeing messages about this previously with the end
result being that mysql 5.1.x was the problem.

Fred
(Guest)
on 2009-02-11 13:22
(Received via mailing list)
Discovered the solution elsewhere and thanks to fred who provide
enough of an addition clue to hunt down other oblique references to
the problem:

The problem is that libmysql.dll shipped with Mysql 5.1 doesn't play
well with ruby 2.2..

The solution is to download the libmysql.dll from:

http://instantrails.rubyforge.org/svn/trunk/Instan...

and save this in your ruby bin directory

see also:
http://forums.aptana.com/viewtopic.php?f=20&t=7563...




On Feb 9, 9:50 pm, Frederick C. <removed_email_address@domain.invalid>
This topic is locked and can not be replied to.