2013-10-25 3 views
0

나는 How to add a Hash object to an ActiveRecord class? Tried but migration fails을 읽고 그 형식을 따릅니다.액티브 레코드 해시에 해시 추가

내가 시도 : 내가 잘못 뭐하는 거지

# Could not dump table "surveys" because of following StandardError 
# Unknown type 'hash' for column 'responses' 

:

class AddTestResponsesToSurveys < ActiveRecord::Migration 
    def change 
     add_column :surveys, :responses, :hash 
    end 
end 

내가 rake db:migrate를 실행, 나는 말한다 내 schema.rb 파일에 오류가?

+0

를 추가합니다. – tihom

답변

1

가 열 텍스트를 입력

class AddTestResponsesToSurveys < ActiveRecord::Migration 
    def change 
     add_column :surveys, :responses, :text 
    end 
end 

그리고 당신의 Survey 모델로 마이그레이션을 생성, 대답은 당신이 링크 게시물 내에이

serialize :responses, Hash