Forum: Ruby on Rails newbie: OSX Ruby/MySQL issue?

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.
2ee8414f94e65771a6b60cd94e26b062?d=identicon&s=25 Tim Jones (Guest)
on 2006-05-09 05:04
(Received via mailing list)
I'm three pages into the OnLamp RoR Tutorial [1] and am wrestling
with what appears to be a MySQL connection problem.

I've created a simple controller called "recipe" with a corresponding
"recipes" mysql table. The recipe controller is just a simple scaffold.

When I browse to "recipe/new", though, I get these errors:
==
NoMethodError in RecipeController#new
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occured while evaluating nil.each
==

Probing further (and checking the archives of this list, esp. [2]), I
tried running script/console and querying MySQL directly. The results
were:
==
 >> ActiveRecord::Base.connection.execute("SHOW FIELDS FROM recipe")
ActiveRecord::StatementInvalid: Mysql::Error: Lost connection to
MySQL server during query: SHOW FIELDS FROM recipe
         from /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/
active_record/connection_adapters/abstract_adapter.rb:120:in `log'
         from /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/
active_record/connection_adapters/mysql_adapter.rb:185:in `execute'
         from (irb):6
==

I've reinstalled all of RoR using a validcode.at bash script [3]--
this supposedly fixed all the standard Tiger-Ruby bugs and enabled
the ruby-mysql library, but I'm still having the same problem.

I've been googling for answers to this all night and am running out
of ideas. Can anyone who's familiar with the particulars of this
setup give some advice?

Running: OSX10.4.4, Ruby 1.8.2, Rails 1.1.2, MySQL 4.1.16

Much thanks in advance for the help,

=Tim Jones=
toneland.net
openboxoffice.com


[1] http://www.onlamp.com/pub/a/onlamp/2005/01/20/rail...
[2] http://news.gmane.org/group/gmane.comp.lang.ruby.r...
[3] http://sg.validcode.at/articles/2006/03/31/the-best-way-to-
install-rails-on-os-x
855ddc9e30065b4061b08a7bd349a0af?d=identicon&s=25 Mats Persson (Guest)
on 2006-05-09 06:57
(Received via mailing list)
Hi Tim,

Not 100% on the same setup as you, but I have the Hivelogic install
working here on X.4.6.

The first and most likely cause of your problems is here:  [ /usr/lib/
ruby/ ]  in the quoted text below

> >> ActiveRecord::Base.connection.execute("SHOW FIELDS FROM recipe")
> ActiveRecord::StatementInvalid: Mysql::Error: Lost connection to
> MySQL server during query: SHOW FIELDS FROM recipe
>         from /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/
> active_record/connection_adapters/abstract_adapter.rb:120:in `log'
>         from /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/
> active_record/connection_adapters/mysql_adapter.rb:185:in `execute'
>         from (irb):6

it should be /usr/local/lib/ruby/...  instead of /usr/lib/ruby/...
Note!  /LOCAL/


and here:  [ Ruby 1.8.2, ]

> Running: OSX10.4.4, Ruby 1.8.2, Rails 1.1.2, MySQL 4.1.16


In simpler terms, you have a problem with your PATH value in the
your .bash_login / .bash_profile file.  Sort that one out, close the
Terminal window (or start a new session, or logout from your user a/
c) and then run this simple test in a new Terminal/iTerm window at
the prompt:

$ ruby -v

and you should get something similar to this returned:   ruby 1.8.4
(2005-12-24) [powerpc-darwin8.6.0]    NB!! the ruby 1.8.4 in there,
anything other than ruby 1.8.4 is NO good

IF things still don't work after this, well then do what I do, check
for typos carefully ;-)   Alternatively, check my signature below for
another Ruby/Rails install alternative :-)


Kind regards,

Mats

----
"TextMate, coding with an incredible sense of joy and ease"
- www.macromates.com -

"RubyOnRails development done the Mac way"
- locomotive.raaum.org -
2ee8414f94e65771a6b60cd94e26b062?d=identicon&s=25 Tim Jones (Guest)
on 2006-05-09 17:34
(Received via mailing list)
Success!

Had to do a huge amount of googling, reinstalling, recompiling, and
solving additional errors but was ultimately able to get things
running thanks to this advice. Much thanks, Mats.

=T=
This topic is locked and can not be replied to.