"No helper clause" error

i making “forget-remind password” at website

1st part –
(get user’s email, send message with url-code to that email)
– all ok

2nd part –
(user go to url-code and set up new password for him account)
— is not ok

(phoenix 1.2.1, Elixir 1.3.1)

in router

get “/remind-password/:email/:remind_code”, PageController, :setup_remind_password
post “/remind-password/:email/:remind_code”, PageController, :do_setup_remind_password

in Controller

def setup_remind_password(conn, %{“email” => email, “remind_code” => remind_code}) do
changeset = Planetwork.EmailRemindPasswordCode.changeset
render conn, “setup_remind_password.html”, changeset: changeset, email: email, remind_code: remind_code
end

def do_setup_remind_password(conn, params) do
case Planetwork.EmailRemindPasswordCode.changeset(%Planetwork.EmailRemindPasswordCode{}, params)
do
{:ok, changeset} →
conn
|> put_session(:user_id, changeset.changes.account_id)
|> redirect(to: “/cabinet”)
{:error, changeset} →
render conn, “setup_remind_password.html”, changeset: changeset, email: params[“email”], remind_code: params[“remind_code”]
end
end

in template

<%= form_for @changeset, page_path(@conn, :do_setup_remind_password), [id: "remind-password-form", class: ""], fn f -> %>
<div class="row">
  <div class="input-field col s12">
    <label for="remind_password_form_password"><%= gettext "Password" %></label>
    <%= password_input f, :password, required: true, class: validate(f, :password), id: "remind_password_form_password" %>
    <%= error_tag f, :password %>
  </div>
</div>
<div class="center">
  <button class="center btn waves-effect" type="submit"><%= gettext "Save password" %></button>
</div>

<% end %>

Why phoenix says that i have error in template at string

<%= form_for @changeset, page_path(@conn, :do_setup_remind_password), [id: “remind-password-form”, class: “”], fn f → %>
???

error

ArgumentError
at GET
/remind-password/usersmail@gmail.com/6crhewhwgqp4sswuyob75k8lz9hicr/
No helper clause for Planetwork.Router.Helpers.page_path defined for action :do_setup_remind_password with arity 2.
Please check that the function, arity and action are correct.
The following page_path actions are defined under your router:

  • :about
  • :do_login
  • :do_setup_password
  • :do_setup_remind_password
  • :do_signup
  • :do_signup
  • :login
  • :login
  • :remind_password
  • :send_remind_password
  • :setup_password
  • :setup_remind_password
  • :signup
  • :signup_with_code

how solve that ?
please help!!

Should be
page_path(@conn, :do_setup_remind_password, [id: “remind-password-form”, class: “”])

Please try. If it works.
Also check the documentation, that the last arg in the function should be a map instead of a list. I don’t remember. I will check up the docs and update here again.

[Edit] I checked out from doc. The last parameter of the path is a keyword list. So putting the last optional args as a list is right. Sorry for bothering putting this point up.

Dev from phone

oh nooo…((

now error looks like –

No helper clause for Planetwork.Router.Helpers.page_path defined for action :do_setup_remind_password with arity 3.
Please check that the function, arity and action are correct.
The following page_path actions are defined under your router

Can you upload the web/routes.ex file I will check for u again tonight

defmodule Planetwork.Router do
use Planetwork.Web, :router

pipeline :browser do
plug :accepts, [“html”]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
plug :put_secure_browser_headers
plug Planetwork.Plug.Locale, “en”
plug Planetwork.Plug.Auth
end

pipeline :api do
plug :accepts, [“json”]
plug Planetwork.Plug.Locale, “en”
end

scope “/”, Planetwork do
pipe_through :browser

get "/", PageController, :login
get "/about", PageController, :about
get "/login", PageController, :login
post "/login", PageController, :do_login
get "/registration", PageController, :signup
post "/registration", PageController, :do_signup
get "/registration/:invitation_code", PageController, :signup_with_code
post "/registration/:invitation_code", PageController, :do_signup
get "/setuppassword/:email/:email_code", PageController, :setup_password
post "/setuppassword/:email/:email_code", PageController, :do_setup_password
get "/remind-password", PageController, :remind_password
post "/remind-password", PageController, :send_remind_password
get "/remind-password/:email/:remind_code", PageController, :setup_remind_password
post "/remind-password/:email/:remind_code", PageController, :do_setup_remind_password
post "/account/login", AccountController, :login
get "/account/logout", AccountController, :logout

get "/cabinet", CabinetController, :index
get "/cabinet/balance", CabinetController, :balance
get "/cabinet/downline", CabinetController, :downline
get "/cabinet/downline/:id", CabinetController, :downline_part
get "/cabinet/invitation-codes", CabinetController, :invitation_codes
post "/cabinet/invitation-codes", CabinetController, :save_invitation_codes
put "/cabinet/invitation-codes", CabinetController, :save_invitation_codes
post "/cabinet/new-invitation-code", CabinetController, :new_invitation_code
put "/cabinet/new-invitation-code", CabinetController, :new_invitation_code
get "/cabinet/profile", CabinetController, :profile
post "/cabinet/profile", CabinetController, :profile_change
put "/cabinet/profile", CabinetController, :profile_change
get "/cabinet/profile/:id", CabinetController, :profile
post "/cabinet/profile/:id/edit", AccountController, :update
resources "/cabinet/shops", CabinetShopsController
resources "/cabinet/volumes", CabinetVolumesController
get "/catalog", CatalogController, :index
get "/admin", AdminController, :index

end

scope “/api”, Planetwork do
pipe_through :api
end

end

you think problem is here?

Ok. So now I try your code in computer and look up for the docs. Sorry for the delay.

The following code path is wrong -

page_path(@conn, :do_setup_remind_password), [id: “remind-password-form”, class: “”]

Since

post “/remind-password/:email/:remind_code”, PageController, :do_setup_remind_password

page_path/4 (arity 4) for u.

So to make it pass - you have to put email, and remindcode as the third and fourth parameter here. - So for sample to make it work please see below code and try to adapt from it. I will put everything in the link helper below.

link(“Some text here”, to: page_path(@conn, :do_setup_remind_password, “email here”, "remind-code-herge))

and if you want to put classes and Id also you can put it as a keyword list at the third parameter of the link function.

link(“Some text here”, to: page_path(@conn, :do_setup_remind_password, “email here”, "remind-code-herge), [class: “classa classb”, id: “Myid”])

Sorry for the delay.
I hope you understand.

1 Like

Those error messages are confusing so I have pushed changes to Phoenix master that make sure everything is a bit more explicit. Now the error should suggest you to use:

page_path(conn_or_endpoint, :do_setup_remind_password, email, remind_code, opts \\ [])

which is basically what @blisscs suggested.

3 Likes