I'm new to using Ecto and Elixir and I've come across an error that I can't explain. My code looks just like the example in the Ecto README.
Here are my modules for the Ecto Model and Query
defmodule Registration do
use Ecto.Model
schema "registrations" do
field :user_id, :string
field :created_at, :datetime, default: Ecto.DateTime.local
field :updated_at, :datetime, default: Ecto.DateTime.local
end
end
defmodule RegistrationQuery do
import Ecto.Query
def by_user(user_id) do
query = from r in Registration,
where: r.user_id == ^user_id,
select: r
Repo.all(query)
end
end
Here is how I call the query function
registrations = Repo.all RegistrationQuery.by_user("underwater")
This all seems exactly in line with the Ecto documentation, and I can't find anything saying otherwise. But I get the following error.
protocol Ecto.Queryable not implemented for [%Ensalutilo.Registration{user_id: "underwater"}]