shansiddiqui94
I am following this tutorial. I have followed carefully correcting errors as I go. The app allows you to create a blog post and add comments if you so choose. I got the Blog post part up and running, I am having difficulty setting up the add comments part when I click show I get this error:
error] #PID<0.918.0> running BlogAppWeb.Endpoint (connection #PID<0.797.0>, stream id 13) terminated
Server: localhost:4000 (http)
Request: GET /posts/1
** (exit) an exception was raised:
** (Protocol.UndefinedError) protocol Enumerable not implemented for #Ecto.Association.NotLoaded<association :comments is not loaded> of type Ecto.Association.NotLoaded (a struct)
(elixir 1.13.3) lib/enum.ex:1: Enumerable.impl_for!/1
(elixir 1.13.3) lib/enum.ex:143: Enumerable.reduce/3
(elixir 1.13.3) lib/enum.ex:4144: Enum.reduce/3
(blog_app 0.1.0) lib/blog_app_web/templates/post/comments.html.eex:7: BlogAppWeb.PostView."comments.html"/1
(blog_app 0.1.0) lib/blog_app_web/templates/post/show.html.heex:19: anonymous fn/2 in BlogAppWeb.PostView."show.html"/1
(phoenix_live_view 0.17.7) lib/phoenix_live_view/engine.ex:124: Phoenix.HTML.Safe.Phoenix.LiveView.Rendered.to_iodata/1
(phoenix_live_view 0.17.7) lib/phoenix_live_view/engine.ex:140: Phoenix.HTML.Safe.Phoenix.LiveView.Rendered.to_iodata/3
(phoenix 1.6.6) lib/phoenix/controller.ex:772: Phoenix.Controller.render_and_send/4
(blog_app 0.1.0) lib/blog_app_web/controllers/post_controller.ex:1: BlogAppWeb.PostController.action/2
(blog_app 0.1.0) lib/blog_app_web/controllers/post_controller.ex:1: BlogAppWeb.PostController.phoenix_controller_pipeline/2
(phoenix 1.6.6) lib/phoenix/router.ex:355: Phoenix.Router.__call__/2
(blog_app 0.1.0) lib/blog_app_web/endpoint.ex:1: BlogAppWeb.Endpoint.plug_builder_call/2
(blog_app 0.1.0) lib/plug/debugger.ex:136: BlogAppWeb.Endpoint."call (overridable 3)"/2
(blog_app 0.1.0) lib/blog_app_web/endpoint.ex:1: BlogAppWeb.Endpoint.call/2
(phoenix 1.6.6) lib/phoenix/endpoint/cowboy2_handler.ex:54: Phoenix.Endpoint.Cowboy2Handler.init/4
(cowboy 2.9.0) /Users/shansiddiqui/Desktop/blog_app/deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2
(cowboy 2.9.0) /Users/shansiddiqui/Desktop/blog_app/deps/cowboy/src/cowboy_stream_h.erl:306: :cowboy_stream_h.execute/3
(cowboy 2.9.0) /Users/shansiddiqui/Desktop/blog_app/deps/cowboy/src/cowboy_stream_h.erl:295: :cowboy_stream_h.request_process/3
(stdlib 3.17) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
and this is what comes on my webpage
My current Github has the updated app, can someone help me figure out what I am doing wrong?
Trending in Questions
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
Anyone here using Honeybadger?
My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of
Bandit.HTTPError...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #ai
- #elixirconf-us
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming












Showing Posts 1 to 7- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
gregvaughn
You need to preload the comments association of the blog before you try to render it. Ecto does not try to read your mind or have mutable state for lazy loading as other db frameworks do.
shansiddiqui94
I am sorry I am a complete beginner here, Would kindly guide me. How could I reload the comments first? the whole page loads at the same time.
gpopides
<%= for comment <- @comments do %>this part tries to iterate over comments, but the comments don’t exist because as top comment mentions you haven’t loaded them.in order to access a related model you need to preload it
shansiddiqui94
In reference to the tutorial, the guide does not do this? Is this because the tutorial is outdated
gregvaughn
I don’t typically go read a beginner tutorial someone else is following, however, in this case I searched the page for “preload” and found under section 3 where comments are added, this is added to the
posts_controller.exThat last line is preloading comments. And a couple of paragraphs later the blog states
shansiddiqui94
Here is my update :
This is my changeset Func:
When I try to create a new Post I get an error that says
changeset Function NOT foundclearly its right there!!Error
al2o3cr
General tip: you’ll get better help if you show the corresponding code along with the error message. What is on line 19 of
lib/blog_app_web/templates/post/show.html.heex?Based on the code up on Github, I’m guessing it’s the same code that’s on line 24 here:
The error is telling you that the view is looking for an assign named
changesetbut not finding it.In the corresponding controller,
changesetis passed to many other calls torenderbut not for theshowaction: