Closed ror6ax closed 8 years ago
Hi @ror6ax! Sorry for the delay.
Did you create your new application with the --sup
flag when calling mix new
? If unsure, does your Stuff
module look similar to this?
defmodule Stuff 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(Stuff.Worker, [arg1, arg2, arg3]),
]
# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: Stuff.Supervisor]
Supervisor.start_link(children, opts)
end
end
The error message that you are seeing looks to be related to how the {Stuff, []}
tuple is being interpreted during the loading of your application. Using the --sup
flag during the call sets up all of this for you automatically, and adding :sugar
to your applications list is pretty straightforward at that point.
To the other side of your question, there shouldn't be any magic necessary for importing and/or using other modules and functions from within a controller. They are pretty basic modules that follow the Plug specification.
Thanks, this works!
I've tweaked the docs a bit to reflect the need to use the --sup
flag, since that wasn't in there previously.
I've created a project by
mix new stuff
Following the documentation, added the app to mix.exs:
Unexpectedly:
Any hints? Also, I'll be looking into calling a separate function asynchronously from controller. Any hidden magic I should expect with regard to importing?