I am trying to understand why this error is raised, how to handle it properly, and of course i am trying to fix the Repo.insert error
note that the error is not raised anymore if i delete father: {} inside
def create_room(attrs \\ %{}) do
%Room{children: [], father: {}, users: []}
|> Room.changeset(attrs)
|> Repo.insert()
end
But i then have the following error :
error] #PID<0.594.0> running GORprojectWeb.Endpoint (cowboy_protocol) terminated
Server: localhost:4000 (http)
Request: POST /api/rooms
** (exit) an exception was raised:
** (Protocol.UndefinedError) protocol Enumerable not implemented for %GORproject.Rooms.Room{__meta__: #Ecto.Schema.Metadata<:loaded, "rooms">, children: [], depth: 1, description: nil, father: #Ecto.Association.NotLoaded<association :father is not loaded>, father_id: nil, id: 25, inserted_at: ~N[2018-10-01 09:52:22.729960], name: "Accueillir", public: false, updated_at: ~N[2018-10-01 09:52:22.733056], users: []}. This protocol is implemented for: DBConnection.PrepareStream, DBConnection.Stream, Date.Range, Ecto.Adapters.SQL.Stream, File.Stream, Function, GenEvent.Stream, HashDict, HashSet, IO.Stream, List, Map, MapSet, Postgrex.Stream, Range, Stream
(elixir) /private/tmp/elixir-20180825-48782-1ofrgzr/elixir-1.7.3/lib/elixir/lib/enum.ex:1: Enumerable.impl_for!/1
(elixir) /private/tmp/elixir-20180825-48782-1ofrgzr/elixir-1.7.3/lib/elixir/lib/enum.ex:141: Enumerable.reduce/3
(elixir) lib/enum.ex:2979: Enum.reduce/3
(gor_project) lib/gor_project_web/router.ex:1: GORprojectWeb.Router.Helpers.segments/3
(gor_project) lib/gor_project_web/router.ex:1: GORprojectWeb.Router.Helpers.room_path/3
(gor_project) lib/gor_project_web/controllers/room_controller.ex:22: GORprojectWeb.RoomController.create/2
(gor_project) lib/gor_project_web/controllers/room_controller.ex:1: GORprojectWeb.RoomController.action/2
(gor_project) lib/gor_project_web/controllers/room_controller.ex:1: GORprojectWeb.RoomController.phoenix_controller_pipeline/2
(gor_project) lib/gor_project_web/endpoint.ex:1: GORprojectWeb.Endpoint.instrument/4
(phoenix) lib/phoenix/router.ex:278: Phoenix.Router.__call__/1
(gor_project) lib/gor_project_web/endpoint.ex:1: GORprojectWeb.Endpoint.plug_builder_call/2
(gor_project) lib/gor_project_web/endpoint.ex:1: GORprojectWeb.Endpoint.call/2
(plug) lib/plug/adapters/cowboy/handler.ex:16: Plug.Adapters.Cowboy.Handler.upgrade/4
(cowboy) /Users/giom/Documents/develop/web/GORProject-API/deps/cowboy/src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4






















