2012-07-27 3 views
0

내가 만든 모델 (카드)의 인스턴스를 만들 때 알 수없는 속성 오류가 나타나는 이유에 대해 누군가가 나에게 몇 가지 힌트를 줄 수 있는지 궁금합니다. 여기에 오류가 발생하는 레이크 작업과 모델 클래스의 제거 된 버전이 있습니다.레일즈 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 

답변

0

보인다. 내 DB가 오래 됐어. 열 이름이 type에서 card_type으로 변경되었습니다.

관련 문제