0

I'm wondering if someone could give me some hints as to why I'm getting an unknown attribute error when trying to create instances of a model I have created (Card). Here is a stripped down version of the model class and the rake task where I am getting the error.

Card class:

class Card < ActiveRecord::Base
  has_and_belongs_to_many :some_other_model
  belongs_to :some_other_other_model
  attr_accessible :attr1, :attr2, :attr3, :attr4,...,:card_type,...
end

rake task:

task :import_cards => :environment do
  # connect to database
  conn = Mysql2::Client.new(yadda yadda yadda)

  results = conn.query("SELECT attr1, attr2, attr3, attr4,..., card_type, ... FROM that_table;")

  results.each{|row|; Card.create(:attr1 => row['attr1'], :attr2 => row['attr2'], :attr3 => row['attr3'], :attr4 => row['attr4'],..., :card_type => row['card_type'],...);}

  conn.close()
end
binarymelon
  • 904
  • 2
  • 12
  • 26

1 Answers1

0

Looks like I had another issue. My db was out of date. Column name had been changed from type to card_type.

binarymelon
  • 904
  • 2
  • 12
  • 26