IO.puts(inspect(contacts)) 给出:
[%HelloTable.Contact{__meta__: #Ecto.Schema.Metadata<:loaded>,
id: 37,
inserted_at: #Ecto.DateTime<2015-10-22T12:50:43Z>,
name: "Gumbo", phone: "(801) 555-55555",
updated_at: #Ecto.DateTime<2015-10-22T12:50:43Z>}]
视图看起来像:
defmodule HelloTable.ContactView do
use HelloTable.Web, :view
def render("index.json", %{contacts: contacts}) do
IO.puts(inspect( contacts ))
contacts
end
end
一旦我尝试渲染这个视图,我就会得到:
** (Poison.EncodeError) unable to encode value: {nil, "contacts"}