lc0815

lc0815

Function Repo.all/1 is undefined (module Repo is not available)

Hello one and all, I am trying to create a full stack app with react and phoenix from an article that uses phoenix 1.3 while I’m using the latest version 1.5.7. in the article, the models db access is used and version 1.5.7 no longer uses the models so my app gives me the following error when I send a get request from postman0

 function Repo.all/1 is undefined (module Repo is not available)

The controller file

defmodule PhxReactList7Web.BlogsController do

  use PhxReactList7Web, :controller

  alias PhxReactList7.Blogs

  def index(conn, _params) do

    blogs = Repo.all(Blogs)

    render conn, "index.json", blogs: blogs

  end

end

the repo file

defmodule PhxReactList7.Repo do

  use Ecto.Repo,

    otp_app: :phx_react_list_7,

    adapter: Ecto.Adapters.Postgres

end

the blogs file

defmodule PhxReactList7.Blogs do

  import Ecto.Query, warn: false

end

Most Liked

kip

kip

ex_cldr Core Team

In the docs, Repo.fun/arity needs to be considered as MyApp.Repo.fun. So in your example, I would suggest adding alias PhxReactList7.Repo in your controller and you should be good to go.

kokolegorille

kokolegorille

That’s the inconvenient following 1.3 tuto, there were no context and no schema, but models…

Also beware of Blog, Blogs, blog, blogs. Because You made some mistakes in the naming.

What You should have is something like PhxReactList7.Blogs.Blog with Blogs being the context, and blog being the schema.

I suggest You start a demo project and initialize a simple resource, and see how it is done with 1.5

With mix phx.gen.context

Where Next?

Popular in Questions Top

_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
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
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
yawaramin
In the Dialyzer docs ( dialyzer — OTP 29.0.2 (dialyzer 6.0.1) ), there is a way to turn off a specific warning for a function: -dialyzer...
New

Other popular topics Top

Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
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
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

We're in Beta

About us Mission Statement