Elixir Phoenix Framework是否允许嵌套资源位于另一个嵌套资源内?

Elixir Phoenix Framework是否允许嵌套资源位于另一个嵌套资源内?,elixir,phoenix-framework,ecto,Elixir,Phoenix Framework,Ecto,就嵌套资源而言,我可以在Phoenix中拥有这样的东西吗 resources "/landlords", LandlordController do resources "/houses", HouseController do resources "/units", UnitController end end 我有房东的地方有很多房子,房子也有很多单元。或者你知道如何做到这一点吗?是的,这是可能的,而且非常普遍。这是实现这一目标的最佳途径。请阅读a以获得更多信息,这里还有一

就嵌套资源而言,我可以在Phoenix中拥有这样的东西吗

resources "/landlords", LandlordController do
  resources "/houses", HouseController do
    resources "/units", UnitController
  end
end

我有房东的地方有很多房子,房子也有很多单元。或者你知道如何做到这一点吗?

是的,这是可能的,而且非常普遍。这是实现这一目标的最佳途径。请阅读a以获得更多信息,这里还有一个示例,说明在这种情况下路线的外观

resources "/users", UserController do
  resources "/posts", PostController
end
生成路由

user_post_path  GET     /users/:user_id/posts           PostController :index
user_post_path  GET     /users/:user_id/posts/:id/edit  PostController :edit
user_post_path  GET     /users/:user_id/posts/new       PostController :new
user_post_path  GET     /users/:user_id/posts/:id       PostController :show
user_post_path  POST    /users/:user_id/posts           PostController :create
user_post_path  PATCH   /users/:user_id/posts/:id       PostController :update
                PUT     /users/:user_id/posts/:id       PostController :update
user_post_path  DELETE  /users/:user_id/posts/:id       PostController :delete

通过这样做,我能够使它工作

resources "/landlords", LandlordController do
  resources "/houses", HouseController
end

resources "/houses", HouseController do
 resources "/units", UnitController
end

因为我尝试了这个(房东房子单元)路径,我得到了一个错误,它不存在stry
mix phx.routes
来查看路由。