Rails嵌套资源问题

时间:2009-07-21 13:16:41

标签: ruby-on-rails routing

我有几个资源,一个grant_application和一个与has_one相关的家庭

class GrantApplication < ActiveRecord::Base
  has_one :household, :dependent => :destroy 
end

class Household < ActiveRecord::Base
  belongs_to :grant_application
end

..我也使用以下路线..

map.resources :grant_applications do |grant|
  grant.resource :household
end

但是,在尝试为/ grant_applications / 1 / household / new创建表单时遇到了实际问题

使用

<% form_for([:grant_application, @household]) do |f| %>

返回错误:

undefined method 'grant_households_path' for #<ActionView::Base:0x23eda44>

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

<% form_for(@household, :url => grant_application_household_path(@grant) ) do |f| %>