Routes's problem - argument error

Hey guys,

I want to get data form my index.html.eex

<section class="phx-hero">
  <h1><%= gettext "Welcome to %{name}!", name: "Phoenix" %></h1>
  <p>Peace of mind from prototype to production</p>

<section class="row">
  <article class="column">
    <%= for produit <- @produits do%>
        <img src="file:///../<%= produit.lienphoto%>" alt="<%= produit.titre %>">   
        <p>€ <%= produit.prix %>,00</p>
        <%= link "Ajout au panier", to: Routes.page_path(@conn, :ajout, produit: produit) %>
    <% end %>

      <%= form_for @conn, Routes.session_path(@conn, :delete), [method: :delete, as: :user], fn _ -> %>
        <div class="form-group">
          <%= submit "logout" %>
      <% end %>
<script type ="text/javascript" src = "<%= Routes.static_path(@conn, "/js/app.js") %>"> </script>

and in my pageController

def ajout(conn, %{"produit" => produit}) do

   produits = get_produit()

   id_u = Plug.Conn.get_session(conn, :user_id)

   id_p =

   IO.puts " aaaaaaaa  #{id_p}  aaaaaaaaaaaaaaa"


   render(conn, "index.html", produits: produits)


And in my router.ex

scope "/", BbmayWeb do

    pipe_through :browser

    get "/", PageController, :index

    get "/page", PageController, :connexion

    get "/pages", PageController, :ajout

    resources "/users", UserController

    resources "/sessions", SessionController, only: [:new, :create, :delete], singleton: true


But I have this problem:

argument error

What’s th problem??

Thank’s for your help

no further error messsages besides “argument error”?
It’s hard to help you with so few details

1 Like

Thank you and sorry to bother you but I’ve found the solution to my problem

Please share your solution in an answer and marked as the solution for this topic.

It’s unpleasant to see topics where the people just look for help but are not willing to share the solution.

I am sure that you don’t like to find them also, especially when they are about the same issue you are looking for an answer, and the author have not bothered to share the solution, just said is sorted out… would you get frustrated with such attitude?


Please share how – it will help future readers.

1 Like