I’m trying to create a POST route to create a book in the database, but the body params are different than the Book schema fields, I tried something like :
POST body :
{
"book" : {
"title": "test"
}
}
In the schema, that field is called “book_title”, how can I associate them ? I tried
book = %Book{
book_title: attrs["title"]
}
changeset = Book.changeset(book, attrs)
case Repo.insert(changeset) do
But now it doesn’t respect the constraints (length etc…) in my changeset