Closed conradwt closed 9 years ago
@conradwt you need to mount the repository in your supervision tree. We have mentioned it in the README and you can see an example in our simple app: https://github.com/elixir-lang/ecto/blob/master/examples/simple/lib/simple.ex#L4-L9 :)
@josevalim I'm using the following unless tree within the above link has special meaning:
defmodule EctoTest do
use Application
# See http://elixir-lang.org/docs/stable/elixir/Application.html
# for more information on OTP Applications
def start(_type, _args) do
import Supervisor.Spec, warn: false
children = [
# Define workers and child supervisors to be supervised
# worker(EctoTest.Worker, [arg1, arg2, arg3])
worker( EctoTest.Repo, [] )
]
# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
# for other strategies and supported options
opts = [ strategy: :one_for_one, name: EctoTest.Supervisor ]
Supervisor.start_link( children, opts )
end
end
That should work too. You just need to specify the EctoTest module so your application is properly started:
https://github.com/elixir-lang/ecto/blob/master/examples/simple/mix.exs#L11
@josevalim Thanks, I was missing the following within the application:
mod: { EctoTest, [] },
Will it ever be possible for Mix to infer the top-level module within the mix.exs?
I don't think that would be good in the long term. The application doesn't have to be in the top-level, you can have multiple app related modules and adds implicit behaviour which can be confusing. :)
I'm seeing the following error when I attempt to insert into the database:
Next, I'm using Elixir 1.1.0-dev and :postgrex, "~> 0.5", :ecto, "~> 0.2.5".