E
Esen Sagynov
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",
assword => "samplepass",
:database => "db_demo"
)
class City < ActiveRecord::Base
end
City.createid => 4, :name => 'Washington')
last_city = City.findlast)
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.
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",
assword => "samplepass",
:database => "db_demo"
)
class City < ActiveRecord::Base
end
City.createid => 4, :name => 'Washington')
last_city = City.findlast)
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.