0

作成したモデル(カード)のインスタンスを作成しようとすると、不明な属性エラーが発生する理由について、誰かがヒントを教えてくれるかどうか疑問に思っています。これは、モデルクラスの簡略版と、エラーが発生しているrakeタスクです。

カードクラス:

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

レーキタスク:

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
4

1 に答える 1

0

別の問題があったようです。私のデータベースは古くなっています。列名が type から card_type に変更されました。

于 2012-07-27T16:07:17.290 に答える