From: Esen Sagynov on
I created very simple AR code to add new record to MySQL table. But I
get " undefined method `debug' for nil:NilClass(NoMethodError)".

Here is the code:
======================================
require 'rubygems'
require 'active_record'

ActiveRecord::Base.establish_connection(
:adapter => "mysql",
:host => "localhost",
:user => "root",
:password => "samplepass",
:database => "db_demo"
)

class City < ActiveRecord::Base
end

City.create(:id => 4, :name => 'Washington')

last_city = City.find(:last)

if last_city
puts %{#{last_city.name} is the last city}
else
puts "There is no any City."
end
======================================

The code is so simple just like explained in
(http://rubylearning.com/satishtalim/ruby_activerecord_and_mysql.html)
and in the Ruby AR documentation. But that undefined method error pops
up anyway. I actually, so many developers encounter the same problem.
Still cannot find the solution.

Any suggestion is appreciated.
--
Posted via http://www.ruby-forum.com/.

From: Brian Candler on
Esen Sagynov wrote:
> I created very simple AR code to add new record to MySQL table. But I
> get " undefined method `debug' for nil:NilClass(NoMethodError)".

I think you need to show the full backtrace. This will show not only
which line in your sample program triggered the error, but also in which
library it occurred.

Also describe your platform: which operating system and version? Which
version of ruby, and where did you install it from? Which version of
active_record? Which version of mysql client library?
--
Posted via http://www.ruby-forum.com/.