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:inlog' 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=
[1] Radar – O’Reilly
[2] http://news.gmane.org/group/gmane.comp.lang.ruby.rails/thread=59878
[3] http://sg.validcode.at/articles/2006/03/31/the-best-way-to-
install-rails-on-os-x