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

Chawki
hi,i’m new to programming world i had learned front-end( javascript,react.js) and i wanna learn a back-end programming language i thought...
New
Fl4m3Ph03n1x
I am doing some exercises while learning Elixir using Exercism.io. Now, my objective is to do all exercises, extras included. This shoul...
New
New
shansiddiqui94
Hello all, I recently did my first app in Phoenix and Liveview, many thanks to all the users who assisted me. I found that the tutorial ...
New
lc0815
hello from a real frustrated newbe… I’m reading this article Full-Stack React With Phoenix (Chapter 3 | Introduction to Phoenix) by mich...
New
Fl4m3Ph03n1x
Background Hello all! So after my controversial introduction with Learning Elixir, frst impressions ( plz don't kill me ! ) - #39 by easc...
New
Fl4m3Ph03n1x
Background After following the communitiy suggestion, I bought the Elixir in Action 2nd Edition book and I am about to finish it now. I ...
New
xgilarb
Hi there, I’m interested in using Elixir because of the rumors about the reliability of the Phoenix framework, and surprisingly, Elixir’...
New
pdgonzalez872
Hi! In my quest of becoming the best Elixir dev I can be, I saw one aspect in my career that I’d like to improve upon. This is language...
New
New

Other popular topics Top

9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

We're in Beta

About us Mission Statement