2017-05-15 1 views
0

를 기록 알 수없는 속성 '상태'ActiveModel :: UnknownAttributeError "레이크 DB : 씨"내가 cmd를 쓸 때

rake aborted!

ActiveModel::UnknownAttributeError: unknown attribute 'status' for Recording. G:/program/Rails/weather/db/seeds.rb:2:in `' Tasks: TOP => db:seed (See full trace by running task with --trace)

내 "seeds.rb"코드, 다음, 나는이 오류가 발생했습니다 당신이 당신의 녹음 테이블의 열이 없기 때문에

`l = Location.create(name: "New York City") 
l.recordings.create(temp: 32, status: "cloudy") 
l.recordings.create(temp: 34, status: "rainy") 
l.recordings.create(temp: 30, status: "rainy") 
l.recordings.create(temp: 28, status: "cloudy") 
l.recordings.create(temp: 22, status: "sunny")` 
+2

속성 또는 관계가 누락되었을 수 있습니다. 'Recording'과'Location' 모델과 마이그레이션을 보여주세요. – Gerry

답변

0

당신은 UnknownAttributeError가 있어요. 상태 열을 아직 생성 했습니까? 그렇지 않은 경우 rails generate migration AddStatusToPRecordings status:string을 할 수 있습니다. 그런 다음 수행하십시오 rake db:migrate

0

Recording 모델의 마이그레이션에 status 속성이 누락되었습니다.

터미널에서 다음 단계를 수행

# add `status` column in `recordings` table 
rails generate migration AddStatusToRecording status:string 
rake db:migrate 

# seed the data into the db 
rake db:seed 

그것이 도움이되기를 바랍니다.

관련 문제