Building a REST API with Phoenix and Elixir

Billperegoy I am stuck at your example ;

Repo.insert(%User{name: "Joe", email: "", password: "secret", stooge: "moe"})

In my case one of my columns in my table is an integer.

Repo.insert(%User{tid: 1, name: “Jimmy”, password: “guessme1”})

When I run the above it fails with

  • * (Ecto.ChangeError) value `1` for `TransportApi.User.tid` in `insert` does not match type :string
  • Even though tid is defined in the model and the table as an integer. What am I missing? Tried giving it as a string thinking some conversion is taking place behind the scenes. But no joy.

Repo.insert(%User{tid: “1”, name: “Jimmy”, password: “guessme1”})
** (ArgumentError) Postgrex expected an integer in -2147483648..2147483647, got “1”. Please make sure the value you are passing matches the definition in your table or in your query or convert the value accordingly.

Like what you read? Give hibbarra a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.