Hi, I am getting this error:
Phoenix.ActionClauseError at PUT /api/books/1
could not find a matching BookListWeb.BookController.update clause to process request. This typically happens when there is a parameter mismatch but may also happen when any of the other action arguments do not match. The request parameters are:
%{"id" => "1", "subtitle" => "Yada"}
Here is the relevant route:
$ mix phx.routes | grep PUT
warning: Plug.Conn.WrapperError.reraise/3 is deprecated. Use reraise/1 or reraise/4 instead.
lib/book_list_web/router.ex:4
PUT /api/users/:id BookListWeb.UserController :update
PUT /api/books/:id BookListWeb.BookController :update
And in book_controller.ex
there is
def update(conn, %{"id" => id, "book" => book_params}) do
...
end
Finally, here is my schema:
defmodule BookList.BookSpace.Book do
use Ecto.Schema
import Ecto.Changeset
schema "books" do
field :author, :string
field :notes, :string, default: "Just started."
field :pages, :integer, default: 10
field :pages_read, :integer, default: 0
field :public, :boolean, default: false
field :rating, :integer, default: 0
field :title, :string
field :subtitle, :string, default: ""
field :user_id, :id
timestamps()
end
@doc false
def changeset(book, attrs) do
book
|> cast(attrs, [:title, :subtitle, :author, :notes, :pages, :pages_read, :rating, :public])
|> validate_required([:title, :author])
end
end