Pow: Pow.Phoenix.RegistrationController not available?

Created on 10 Sep 2018  ·  8Comments  ·  Source: danschultzer/pow

I've followed the Getting Started (Phoenix) section in the README to the letter but when I 'fire up' the iex -S mix phx.server and try going to localhost:4000/registration/new I'm told that

$ iex -S mix phx.server
Erlang/OTP 21 [erts-10.0.7] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe] [dtrace]

[info] Running PowwowWeb.Endpoint with Cowboy using http://0.0.0.0:4000
Interactive Elixir (1.7.3) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> 10:25:47 - info: compiled 6 files into 2 files, copied 3 in 874 ms
[info] GET /registration/new
[info] Sent 500 in 69ms
[error] #PID<0.398.0> running PowwowWeb.Endpoint (cowboy_protocol) terminated
Server: localhost:4000 (http)
Request: GET /registration/new
** (exit) an exception was raised:
    ** (UndefinedFunctionError) function PowwowWeb.Pow.Phoenix.RegistrationController.init/1 is undefined (module PowwowWeb.Pow.Phoenix.RegistrationController is not available)
        PowwowWeb.Pow.Phoenix.RegistrationController.init(:new)
        (powwow) lib/powwow_web/router.ex:1: anonymous fn/1 in PowwowWeb.Router.__match_route__/4
        (phoenix) lib/phoenix/router.ex:278: Phoenix.Router.__call__/1
        (powwow) lib/powwow_web/endpoint.ex:1: PowwowWeb.Endpoint.plug_builder_call/2
        (powwow) lib/plug/debugger.ex:122: PowwowWeb.Endpoint."call (overridable 3)"/2
        (powwow) lib/powwow_web/endpoint.ex:1: PowwowWeb.Endpoint.call/2
        (plug) lib/plug/adapters/cowboy/handler.ex:16: Plug.Adapters.Cowboy.Handler.upgrade/4
        (cowboy) /Users/Walther/tmp/meetup/powwow/deps/cowboy/src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4
[info] GET /
[debug] Processing with PowwowWeb.PageController.index/2
  Parameters: %{}
  Pipelines: [:browser]
[info] Sent 200 in 12ms

Any ideas?

Most helpful comment

No problem!

I usually keep my app paths in a separate scope like this:

scope "/" do
  pipe_through :browser

  pow_routes()
end

scope "/", PowWeb do
  pipe_through :browser

  get "/", PageController, :index
end

All 8 comments

You probably have the routes set up like this:

  scope "/", Powweb do
    pipe_through :browser

    pow_routes()
  end

You should remove the Powweb namespace so it looks like this:

  scope "/" do
    pipe_through :browser

    pow_routes()
  end

I did too - but it did not help changing the namespace like your suggestion :(

I'm on macOS 10.13.5, Erlang 21.0.8, Elixir 1.7.3 if that might have anything to do with it?

I’ve almost the same setup. Can you post the content of router.ex?

🤦‍♂️ edited the wrong app (I've been trying out several to see if I could circumvent the issue)

it works!

but what about the

# scope "/", MyAppWeb do
#   pipe_through [:browser, :protected]
#
#   # Add your protected routes here
# end

what is that for?

Thank you so much for sharing this!

/Walther

Great! That's where you put your protected resources that requires authentication to view (e.g. a user dashboard).

sorry to comment on this closed issue - but my scope did look like this

scope "/", PowWeb do
  pipe_through :browser

  pow_routes()
  get "/", PageController, :index
end

and removing the PowWeb namespace did allow me to hit the registration/new url - but at the same time it did 'kill' the "/" url

so, it has to look like this:

scope "/" do
  pipe_through :browser

  pow_routes()
  get "/", PowWeb.PageController, :index
end

No problem!

I usually keep my app paths in a separate scope like this:

scope "/" do
  pipe_through :browser

  pow_routes()
end

scope "/", PowWeb do
  pipe_through :browser

  get "/", PageController, :index
end

v1.0.1 has been released that raises an error with instructions when the scope is incorrect to prevent this confusion :rocket:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danschultzer picture danschultzer  ·  3Comments

JonRCahill picture JonRCahill  ·  3Comments

Kaquadu picture Kaquadu  ·  4Comments

jung-hunsoo picture jung-hunsoo  ·  3Comments

rushsteve1 picture rushsteve1  ·  6Comments