No Method Error - Active Record

I posted this in the Ruby forum but I was told it would be more at home
here.

I’m very new to ruby so for all I know this could be ridiculously easy.
Thank you in advance for any and all suggestions!

Here is the error:
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2962:in
log_protected_attribute_removal': undefined methoddebug’ for
nil:NilClass (NoMethodError)
from
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2946:in
remove_attributes_protected_from_mass_assignment' from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2739:inattributes=’
from
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:2439:in
initialize' from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:726:innew’
from
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/base.rb:726:in
create' from ./read_categories.rb:42 from /home/emergenc/RubyGems/gems/parseexcel-0.5.2/lib/parseexcel/worksheet.rb:143:ineach’
from
/home/emergenc/RubyGems/gems/parseexcel-0.5.2/lib/parseexcel/worksheet.rb:143:in
`each’
from ./read_categories.rb:41

When I traced it in the code this error is what would be displayed if
that debug undefined method error wasn’t there:
“WARNING: Can’t mass-assign these protected attributes:
#{attributes.join(’, ')}”

Here is the relevant code:
#!/usr/bin/ruby
ENV[‘GEM_PATH’] = ‘/home/emergenc/RubyGems:/usr/lib/ruby/gems/1.8’
require ‘rubygems’;
require ‘parseexcel’
require ‘net/ftp’
require ‘activerecord’
require ‘csv’

#Make Database Connection
ActiveRecord::Base.establish_connection(:adapter=>“mysql”,:host=>“localhost”,:username=>“xxxxxxx”,:password=>“xxxxx”,:database=>“e_shop”)

class Category < ActiveRecord::Base
end
class Subcategory < ActiveRecord::Base
end
class Item < ActiveRecord::Base
end

#Open the excel file
cat_worksheet =
Spreadsheet::ParseExcel.parse("/home/emergenc/DataFiles/categories.xls").worksheet(0)
subcat_worksheet =
Spreadsheet::ParseExcel.parse("/home/emergenc/DataFiles/subcategories.xls").worksheet(0)

#Delete Currently Existing Data
Category.connection.execute(“TRUNCATE TABLE categories”)
Subcategory.connection.execute(“TRUNCATE TABLE subcategories”)
Item.connection.execute(“TRUNCATE TABLE items”)

(I CUT OUT IRRELEVANT CODE, LINE 39 Starts with #LOAD, LINE 40 starts
with cat_w…, and LINE 41 starts with Category.create to map from the
error message)
#Load Category Data
cat_worksheet.each(1) do |row|
Category.create(:description=>(row.at(1).to_s(‘latin1’)).split(/\s+/).each{
|word| word.capitalize! }.join(’ ‘), :id => row.at(0).to_s(‘latin1’))
unless row.nil?
end
Category.connection.execute("UPDATE categories c SET grouping_id =
(SELECT max(id) FROM groupings g where lower(c.description) like
concat(’%’,lower(g.description),’%’))")
Category.connection.execute("UPDATE categories c SET grouping_id =
(SELECT grouping_id FROM grouping_overrides g where c.description =
g.category_desc) WHERE grouping_id is nul$
Category.connection.execute(“UPDATE categories c SET grouping_id =
(SELECT id FROM groupings g where g.description = ‘Other Items’) where
grouping_id is null”)

For anyone searching for a solution to this:

Add ActiveRecord::Base.logger = Logger.new("debug.log) before the
database connection.

(Care of halogenandtoast on IRC)