2010-03-20 3 views
3

나는 high_school에 속한 중첩 모델 학생이 있습니다.레일에서 Form_for의 템플릿 오류

No route matches {:action=>"destroy", :controller=>"students", :high_school_id=> # <HighSchool id: 1, name: "cool place", ... } 

<%= form_for @student, :url => high_school_student_path(@high_school, @student), :html => { :multipart => true } do |f| %> 

내가 정말 단순하고 바보 '내가 할 수있는 일을하고 있다고 생각 : 문제는 내가 새로운 학생을 만들 갈 때 (/ 1/학생/새/high_schools가) 나는이 오류가 있다는 것입니다 생각 해봐.

내 환경 : Rails3 및 Ruby1.9.2dev

감사합니다!

+1

경로는 무엇입니까? – shingara

+0

매우 비슷한 문제가 있습니다. 일반적인 RESTful 모델은 해당 자원의 삭제 작업에 '경로 일치 없음'을 던지고 있습니다. Eric : Responders gem을 사용 하시겠습니까? –

답변

0

어쩌면 추가 routes.rb

컨트롤러

delete 'student' => :destroy 

학생들에게

 delete 'student' => :destroy 

1

이 form_for 첫 번째 인수로 배열을 전달하는 시도하고 제거 할 the : url 해시.

<%= form_for [@high_school, @student], :html => { :multipart => true } %> 

그리고 @student가 새 레코드인지 확인하십시오.