많은 상태를 가진 비디오라는 모델이 있습니다. 나는 각 종류의 상태를 만들고 그것을 @ Video.statuses에 추가하기를 원한다. VideosController에서Ruby on Rails에서 다른 모델을 만들 때 자동으로 모델 생성
, 나는이 :
def create
@video = Video.new(params[:video])
Kind.all.each do |f|
@video.statuses.new(:kind =>f, :kind_id=>f.id,:comment =>"", :time_comp => nil, :completed =>false, :video_id =>@video.id)
end
respond_to do |format|
if @video.save
format.html { redirect_to @video, notice: 'Video was successfully created.' }
format.json { render json: @video, status: :created, location: @video }
else
format.html { render action: "new" }
format.json { render json: @video.errors, status: :unprocessable_entity }
end
end
end
그러나, 이것은에서 상태가 올바르지 때문에 영상이 저장되지 않을 수 있다고 말한다 오류를 반환합니다. 내 전체 프로젝트의 유일한 유효성 검사는 상태이며 video_id가 있는지 확인하는 것입니다. 나는이 오류가 발생하는 이유를 매우 혼란스럽게 생각하며 도움을 주셔서 감사합니다! ,
https://github.com/ninajlu/videos