wolfiton

wolfiton

Programming phoenix Chapter 3. Controllers page 54

Hi everyone,

Problem in programming phoenix page 55

Error trace:

[info] GET /users/
[debug] Processing with RumblWeb.UserController.index/2
  Parameters: %{}
  Pipelines: [:browser]
[info] Sent 500 in 53ms
[error] #PID<0.435.0> running RumblWeb.Endpoint (connection #PID<0.434.0>, stream id 1) terminated
Server: localhost:4000 (http)
Request: GET /users/
** (exit) an exception was raised:
    ** (ArgumentError) assign @user not available in eex template.

Please make sure all proper assigns have been set. If this
is a child template, ensure assigns are given explicitly by
the parent template as they are not automatically forwarded.

Available assigns: [:conn, :users, :view_module, :view_template]

        (phoenix_html) lib/phoenix_html/engine.ex:133: Phoenix.HTML.Engine.fetch_assign!/2
        (rumbl) lib/rumbl_web/templates/user/index.html.eex:2: RumblWeb.UserView."index.html"/1
        (rumbl) lib/rumbl_web/templates/layout/app.html.eex:26: RumblWeb.LayoutView."app.html"/1
        (phoenix) lib/phoenix/view.ex:410: Phoenix.View.render_to_iodata/3
        (phoenix) lib/phoenix/controller.ex:729: Phoenix.Controller.__put_render__/5
        (phoenix) lib/phoenix/controller.ex:746: Phoenix.Controller.instrument_render_and_send/4
        (rumbl) lib/rumbl_web/controllers/user_controller.ex:1: RumblWeb.UserController.action/2
        (rumbl) lib/rumbl_web/controllers/user_controller.ex:1: RumblWeb.UserController.phoenix_controller_pipeline/2
        (phoenix) lib/phoenix/router.ex:288: Phoenix.Router.__call__/2
        (rumbl) lib/rumbl_web/endpoint.ex:1: RumblWeb.Endpoint.plug_builder_call/2
        (rumbl) lib/plug/debugger.ex:122: RumblWeb.Endpoint."call (overridable 3)"/2
        (rumbl) lib/rumbl_web/endpoint.ex:1: RumblWeb.Endpoint.call/2
        (phoenix) lib/phoenix/endpoint/cowboy2_handler.ex:42: Phoenix.Endpoint.Cowboy2Handler.init/4
        (cowboy) /home/dan/Codes/rumbl/deps/cowboy/src/cowboy_handler.erl:41: :cowboy_handler.execute/2
        (cowboy) /home/dan/Codes/rumbl/deps/cowboy/src/cowboy_stream_h.erl:320: :cowboy_stream_h.execute/3
        (cowboy) /home/dan/Codes/rumbl/deps/cowboy/src/cowboy_stream_h.erl:302: :cowboy_stream_h.request_process/3
        (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3

I know that this errors tell me that I don’t have assigned to the template the value of user but i did using this:

Content from :user/index.html.eex

<tr>
<td><%= render("user.html", user: @user) %></td>
<td><%= link "View", to: Routes.user_path(@conn, :show, @user.id) %></td>
</tr>

Content from :user/show.html.eex

<h1>Showing User</h1>
<%= render "user.html", user: @user %>

Content from: user/user.html.eex
<strong><%= first_name(@user) %></strong> (<%= @user.id %>)

So why does phoenix tell me that i haven’t assigned user in the template?

Thanks in advance

Most Liked

NobbZ

NobbZ

:users is not @user, your index.html.eex is wrong.

NobbZ

NobbZ

And we are back to singular vs plural.

Where Next?

Popular in Chat/Questions Top

nur
https://e.planaria.network/stack.png https://e.planaria.network Build a NoSQL DB, Build a Relational SQL Database, Build a Graph Datab...
New
Iex.new
Hello!, I just started this week to discover Elixir. I’m a PHP-Programmer and did some sutff in Go too. The more I read about Elixir t...
New
Scoty
Hey, I am currently reading Programming Elixir and I am doing one of the exercises where you should write a solution to the “I’m thinkin...
New
RKC07
I’m new to elixir. I did some coding in python and C. I want to learn elixir for starting my career in web development. I need suggestion...
New
Allyedge
Hey, I want to learn Elixir OTP and I wanted to know if there are any good resources that teach it. I found some web pages, but none of t...
New
ericmachine88
Hi all, I am currently on this course Half a way thru, and struggled a bit… sometimes I don’t even know what I am coding especially ...
New
Kielo
Hi, I run a language learning blog and would like to learn how to code so I can create an app to help English speakers learn French. I ...
New
logesh
Could someone provide a learning path for functional programming for who came from oops background.? Thanks in advance
New
SavagePixie
I was wondering if there are any beginner-friendly, exercise-based resources for learning Elixir out there. I’m looking for something lik...
New
Fl4m3Ph03n1x
Background I am trying to do the typical Ceaser cypher exercise in Elixir. The description of the exercise is as follows: Create an impl...
New

Other popular topics Top

yurko
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
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
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

We're in Beta

About us Mission Statement