If I have this in my router:
scope "/", MyApp do
pipe_through :browser
# resources "/reset_password", ResetPasswordController, only: [:edit, :update]
get "/reset_password", ResetPasswordController, :edit
put "/reset_password", ResetPasswordController, :update
end
scope "/api", MyApp do
pipe_through :api
scope "/v1" do
resources "/reset_password", ResetPasswordController, only: [:create]
end
end
This code works in my controller test:
conn = post(conn, reset_password_path(conn, :create), reset_password: %{email: "anna@example.com"})
However, if I change the get
and put
to also use resources
, like this:
scope "/", MyApp do
pipe_through :browser
resources "/reset_password", ResetPasswordController, only: [:edit, :update]
end
scope "/api", MyApp do
pipe_through :api
scope "/v1" do
resources "/reset_password", ResetPasswordController, only: [:create]
end
end
This code throws an error:
conn = post(conn, reset_password_path(conn, :create), reset_password: %{email: "anna@example.com"})
** (Protocol.UndefinedError) protocol Phoenix.Param not implemented for [reset_password_token: "Kz5RHRYMSedylzSJOz8oItFl255GsR-crTCa8Q1DJDTlQYv5OMFknS5OPj-HRcjQ"]
Why would one work but not the other? Also, why would changing the get
/put
routes break the post
?
Is it because I use resources
twice, and in different scopes?