1
看着Phoenix,是否有相当于shallow
的路由,类似于rails如何实现此目的?Phoenix框架中的浅层嵌套路由
这将允许您引用的/posts/1
代替/users/2/posts/1
例如,
resources "/users", UserController do resources "/posts", PostController, shallow: true end
看着Phoenix,是否有相当于shallow
的路由,类似于rails如何实现此目的?Phoenix框架中的浅层嵌套路由
这将允许您引用的/posts/1
代替/users/2/posts/1
例如,
resources "/users", UserController do resources "/posts", PostController, shallow: true end
看起来不像Phoenix.Router.resources/4
支持:shallow
选择,但这将完成这项工作:
resources "/users", UserController do
resources "/posts", PostController, only: [:index, :new, :create]
end
resources "/posts", PostController, except: [:index, :new, :create], as: :user_post
在mix phoenix.routes
你的其他呃路线,你会看到:
user_post_path GET /users/:user_id/posts YourApp.PostController :index
user_post_path GET /users/:user_id/posts/new YourApp.PostController :new
user_post_path POST /users/:user_id/posts YourApp.PostController :create
user_post_path GET /posts/:id/edit YourApp.PostController :edit
user_post_path GET /posts/:id YourApp.PostController :show
user_post_path PATCH /posts/:id YourApp.PostController :update
PUT /posts/:id YourApp.PostController :update
user_post_path DELETE /posts/:id YourApp.PostController :delete