ExAdmin / Phoenix complaining about a date field

Hey folks,

I’m wondering if someone could help me with this, I’m very new to using both ExAdmin and Phoenix.

I’m trying to save a User’s date of birth.

In my Postgres table the field is a date
In my Ecto schema the field is a :date
In my ExAdmin form I’ve tried using the standard text field and also a date field

When I attempt to save the error I get is;

protocol Enumerable not implemented for ~D[1980-09-07]

The data looks to be going through okay;

%{"dob" => "1980-09-07" ...}

When adding a user from iex passing in dob as a string (as above) seems to work fine.

Any guidance would be greatly appreciated.

Edit with stack trace

[info] POST /admin/admins/11141bea-5fc9-41a0-8393-106b106d2903
[debug] Processing with ExAdmin.AdminResourceController.update/2
  Parameters: %{"_csrf_token" => "AiAGcCdpSTkoYDMNDyEVJB4dCDw4JgAA2hT7uQ+iNVITEVlqd6OYuQ==", "_method" => "put", "admin" => %{"dob" => "2017-06-27", "email" => "toby.osbourn@gmail.com", "first_name" => "Toby", "gocardless_user_id" => "", "intercom_id" => "", "last_name" => "Osbourn", "mangopay_user_id" => ""}, "commit" => "Update User", "id" => "11141bea-5fc9-41a0-8393-106b106d2903", "resource" => "admins", "utf8" => "✓"}
  Pipelines: [:browser]
[debug] QUERY OK source="users" db=1.5ms decode=0.2ms queue=0.3ms
SELECT u0."id", u0."email", u0."first_name", u0."last_name", u0."dob", u0."password_hash", u0."last_recorded_ip", u0."last_recorded_device", u0."mangopay_user_id", u0."gocardless_user_id", u0."intercom_id", u0."account_on_hold", u0."on_watch_list", u0."deleted_at", u0."inserted_at", u0."updated_at" FROM "identity"."users" AS u0 WHERE (u0."id" = $1) [<<17, 20, 27, 234, 95, 201, 65, 160, 131, 147, 16, 107, 16, 109, 41, 3>>]
[info] Sent 500 in 25ms
[error] #PID<0.1406.0> running Admin.Web.Endpoint terminated
Server: localhost:5000 (http)
Request: POST /admin/admins/11141bea-5fc9-41a0-8393-106b106d2903
** (exit) an exception was raised:
    ** (Protocol.UndefinedError) protocol Enumerable not implemented for ~D[2017-06-27]
        (elixir) lib/enum.ex:1: Enumerable.impl_for!/1
        (elixir) lib/enum.ex:116: Enumerable.reduce/3
        (elixir) lib/enum.ex:1767: Enum.map/2
        (elixir) lib/enum.ex:1233: anonymous fn/3 in Enum.map/2
        (stdlib) lists.erl:1263: :lists.foldl/3
        (elixir) lib/enum.ex:1772: Enum.map/2
        (ex_admin) web/ex_admin/errors_helper.ex:36: ExAdmin.ErrorsHelper.flatten_errors/3
        (ex_admin) web/ex_admin/errors_helper.ex:29: ExAdmin.ErrorsHelper.create_errors/2
        (ex_admin) web/controllers/admin_resource_controller.ex:5: ExAdmin.AdminResourceController.handle_changeset_error/4
        (ex_admin) web/controllers/admin_resource_controller.ex:1: ExAdmin.AdminResourceController.action/2
        (ex_admin) web/controllers/admin_resource_controller.ex:1: ExAdmin.AdminResourceController.phoenix_controller_pipeline/2
        (admin) lib/admin/web/endpoint.ex:1: Admin.Web.Endpoint.instrument/4
        (phoenix) lib/phoenix/router.ex:278: Phoenix.Router.__call__/1
        (admin) lib/admin/web/endpoint.ex:1: Admin.Web.Endpoint.plug_builder_call/2
        (admin) lib/plug/debugger.ex:123: Admin.Web.Endpoint."call (overridable 3)"/2
        (admin) lib/admin/web/endpoint.ex:1: Admin.Web.Endpoint.call/2
        (plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4
        (cowboy) /Users/tosbourn/Projects/PiggyPot/zeus/deps/cowboy/src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4

Could you possibly provide some more info and/or the full stack trace for this issue? From what you described, it seems like the data is being saved correctly, however, something is trying to enumerate over the date field that you have defined after the user is saved. Of course, whatever that is cannot enumerate over a single element (~D[1980-09-07]), so it’s probably expecting a list of dates or something like that.

That was a dumb omission on my part! Added the stack trace to the original post.

It doesn’t appear to be saving the data, at least the DB isn’t updating with it.

What is odd is you are correct in that it seems to think the save has happened okay (the POST isn’t returning an error)