是否允许在凤凰城以字符串形式发布查询?

时间:2017-05-26 03:52:06

标签: elixir phoenix-framework

例如,调用

GET /users/1/items/2?foo=bar

调用show(conn,params)和“foo”=> “酒吧”在我的参数中

帖子的等价物是什么?

POST /users/1/items/2?foo=bar

它没有点击我的更新功能。相反,我看到了:

  

**(Phoenix.Router.NoRouteError)找不到POST / users / 1 / items / 2(MyApp.Router)的路由

编辑:其他信息

#routes
resources "/users", UserController do
  resources "/items", ItemController
end

#the template code calling it
<%= user_item_path(@conn, :update, @user, @item, %{"foo" => "bar"}) %>
#I've also tried the post string above

1 个答案:

答案 0 :(得分:3)

resourcesPUT操作定义了PATCHupdate路由。如果您将请求中的POST方法更改为PUTPATCH,则应在行动中的参数中获得"foo" => "bar"