andrewb

andrewb

Undefined function session_path/2

Hi,

I am having trouble debugging an error:

== Compilation error in file lib/booking_central_web/views/session_view.ex ==
** (CompileError) lib/booking_central_web/templates/session/register.html.eex:9: undefined function session_path/2
(stdlib) lists.erl:1338: :lists.foreach/2
(stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
(elixir) lib/kernel/parallel_compiler.ex:198: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/6

Here is my router:

    scope "/", BookingCentralWeb do
    pipe_through :browser # Use the default browser stack

    get "/", DashboardController, :index
    
    get "/login", SessionController, :login_form
    get "/register", SessionController, :register_form
    post "/register", SessionController, :register_user
    end

I have a controller:

defmodule BookingCentralWeb.SessionController do
  
  use BookingCentralWeb, :controller

  alias BookingCentral.Accounts.{Registration}

  plug :put_layout, "accounts.html"

    def login_form(conn, _params) do
        render conn, "login.html"
    end

    def register_form(conn, _params) do
        changeset = Registration.changeset(%Registration{})
        render conn, "register.html", changeset: changeset
    end

    def register_user(conn, %{"registration_params" => params}) do
        IO.inspect params
        render conn, "login.html"
    end

end

Here is my View:

defmodule BookingCentralWeb.SessionView do
  use BookingCentralWeb, :view
end

And I am referencing the session_path in my form:

<%= form_for @changeset, session_path(@conn, :register_user), fn f -> %>

Any suggestions for working out why I get this error are appreciated.

Andrew

Marked As Solved

sanswork

sanswork

Are you using Phoenix 1.4 by chance? You need to use Routes.session_path() if you are.

Also Liked

sanswork

sanswork

get "/login", SessionController, :login_form
get "/register", SessionController, :register_form
post "/register", SessionController, :register_user

All three of those should define session_path in 1.3

andrewb

andrewb

Thanks … this is it!

Last Post!

andrewb

andrewb

There is a new alias Routes for all of the generated paths

Where Next?

Popular in Questions Top

baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs &amp; Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 130579 1222
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 44608 311
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New

We're in Beta

About us Mission Statement