I just started working with Elixir and Phoenix today, I'm trying to add Ecto as a mapper, but I am having problems using time.
This is my model.
schema "users" do field :name, :string field :email, :string field :created_at, :datetime, default: Ecto.DateTime.local field :updated_at, :datetime, default: Ecto.DateTime.local end
I am trying to set created_at and updated_at by default, but when I try to compile this, I get the following error.
== Compilation error on file web/models/user.ex == ** (ArgumentError) invalid default argument `%Ecto.DateTime{day: 13, hour: 19, min: 47, month: 2, sec: 12, year: 2015}` for `:datetime` lib/ecto/schema.ex:687: Ecto.Schema.check_default!/2 lib/ecto/schema.ex:522: Ecto.Schema.__field__/4 web/models/board.ex:9: (module) (stdlib) erl_eval.erl:657: :erl_eval.do_apply/6
You can find little in the documentation, what would be the right way?
postgresql elixir ecto
MartinElvar
source share