1

在我的路线文件中,我有

  resources :contractors, :path => '/' 
  resources :customers, :path => '/'

注意:两者都有自己的注册/设计模型。

现在的问题是,如果contractor登录。他可以正常浏览。但是当customer登录它说Couldn't find Contractr with id=1。现在如果我颠倒顺序

    resources :customers, :path => '/'
  resources :contractors, :path => '/' 

它适用于客户而不适用于承包商。我想我知道这里的问题是什么。但是我该如何解决呢?我不知道希望/customers//contractors/作为 URL 中的前缀

4

1 回答 1

0

如果您想拥有到 2 个不同资源的相同路径,则应该确定范围:

devise_scope(:contractor) { resources :contractors, path: '/' }
devise_scope(:customer)   { resources :customers,   path: '/' }
于 2013-05-29T07:51:15.567 回答