0
我想知道如果有人能夠給我一些提示,說明爲什麼當我嘗試創建我創建的模型(卡)的模型實例時,我得到未知屬性錯誤。這裏是模型類的剝離版本和rake任務,我收到錯誤。Rails 3:未知屬性
卡類:
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