3

我有一个属于 high_school 的嵌套模型学生。问题是当我去创建一个新学生(/high_schools/1/students/new)时,我收到了这个错误:

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| %>

我想我只是在做一些我想不到的非常简单和愚蠢的事情。

我的环境:Rails3 和 Ruby1.9.2dev

谢谢!

4

2 回答 2

1

尝试将数组作为第一个参数传递给 form_for,并删除 :url 哈希。

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

并确保@student 是一个新记录。

于 2010-11-08T23:24:33.890 回答
0

也许添加

delete 'student' => :destroy

在路线.rb

控制器:学生做

     delete 'student' => :destroy

结尾

于 2010-05-20T10:22:47.253 回答