Programming Phoenix question: Matching on "create" action
I'm going through the Programming Phoenix book and I'm confused about second argument in the create action on a form submission. Where does this map we match against come from and how do I know the key is user?
It's different than in the example where the atom is in the route get "/users/:id", MyApp.UserController, :show and it was obvious from the docs that a map was generated and "id" was the key.
In the book it's:
def create(conn, %{"user" => user_params})
changeset = User.changeset(%User{}, user_params)
{:ok, user} = Repo.insert(changeset)
conn |> redirect(to: user_path(conn, :index))
end
When you submit the form, what map is being sent and how do I know it's keys?
Posted May 29, 2016, 8:43 PM UTC
72