I've just installed all what i need to learn Ruby on Rails. I've got a Sitepoint book that runs through a tutorial on building a site similar to Digg, and it's discussing 'Saving an Object' which i run through the ruby console:
from that i run:
>> class Story < ActiveRecord::Base; end
I then went to enter the next line:
>> story = Story.new
i got the following error returned when i entered story = Story.new
ActiveRecord::StatementInvalid: Mysql::Error: Unknown system variable 'NAMES': SET NAMES 'utf8'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:150:in `log'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/mysql_adapter.rb:281:in `execute'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/mysql_adapter.rb:472:in `connect'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/mysql_adapter.rb:165:in `initialize'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/mysql_adapter.rb:88:in `new'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/mysql_adapter.rb:88:in `mysql_connection'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:291:in `send'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:291:in `connection='
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:259:in `retrieve_connection'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:78:in `connection'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1080:in `columns'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:2363:in `attributes_from_column_definition_without_lock'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/locking/optimistic.rb:55:in `attributes_from_column_definition'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1922:in `initialize'
I picked up that same book you are using by Patrick Lenz.
Although I can't offer you advice to the error at hand, I can tell you that you should stop using that book and save yourself some time.
The book is fairly outdated and with all the new updates, it is a new playing field. I suggest you look for a new tutorial, I've been looking into this site http://www.pragprog.com/
I'm up to about chapter 6 in Lenz's book and i have just about had it with asking people and looking for workarounds due to the newer updates.
Here are the time consuming issues I have encountered. I run Leopard so maybe not all these issues apply to you.
1) Chapter 2: Issue with Mac OS 10.5 defaulting to SQLite Database adapter even after installing mysql (a simple fix)
2) as a result of the first issue... Not all databases were auto created as Lenz says in his book and have to be manually created(also a simple fix, but takes a bit of looking)
3) In one chapter you will have to call a scaffold method within a controller and you will get a Scaffold method error. It turns out that rails ditched the Scaffold method in its latest update. Of course Lenz couldn't predict this but if you want to continue the tutorial you will have to create it manually with .script/generate scaffold, this is tricky and i still can't figure it out completely since you have to append attributes to the to the newly generated scaffold.
Like I said, try a newer tutorial. And if its Digg you want your site modeled after you can always come back when you are a bit more knowledeable and gander through his code archive.
Hope this helps, and if you have any help to give me with that third issue I mentioned above, i wouldn't mind trying since i already have put a lot of time into lenz's tutorial.