Rails:嵌套资源

以下路径引发错误:

= link_to 'Subscribers', user_subscribers_path(current_user) 

的未定义方法`user_subscribers_path’

我不知道为什么。

我已经定义了我的路线如下:

  resources :users, :only => [:show, :index], :has_many => :subscribers, :shallow => true 

谢谢!

EDIT rake路线没有显示任何特别有用的东西。 订阅者只有两行:

 users GET /users(.:format) users#index {:has_many=>:subscribers} user GET /users/:id(.:format) users#show {:has_many=>:subscribers} 

您需要在路由文件中定义资源订户,如下所示

 resources :users do resources :subscribers end 

这将为您的资源创建所需的路径助手

对于浅路线,您可以使用

  map.resources :users, :shallow => true do |user| user.resources :subscribers end