Ecto.Queryable not implemented for User / Phoenix Error












1















Following along with the Programming Phoenix 1.4 book. The module worked fine when I was using a manual database, but when I tried to switch my accounts.ex file (like the book told me to do), it broke:



defmodule Rumbl.Accounts do
alias Rumbl.Repo

def get_user(id) do
Repo.get(User, id)
end

def get_user!(id) do
Repo.get!(User, id)
end

def get_user_by(params) do
Repo.get_by(User, params)
end

def list_users do
Repo.all(User)
end
end


Here's the full error I get when I changed my account.ex file:



[error] #PID<0.732.0> running RumblWeb.Endpoint (connection #PID<0.731.0>, stream id 1) terminated
Server: localhost:4000 (http)
Request: GET /users
** (exit) an exception was raised:
** (Protocol.UndefinedError) protocol Ecto.Queryable not implemented for User, the given module does not exist. This protocol is implemented for: Atom, BitString, Ecto.Query, Ecto.SubQuery, Tuple
(ecto) lib/ecto/queryable.ex:40: Ecto.Queryable.Atom.to_query/1
(ecto) lib/ecto/repo/queryable.ex:14: Ecto.Repo.Queryable.all/3
(rumbl) lib/rumbl_web/controllers/user_controller.ex:7: RumblWeb.UserController.index/2
(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
(rumbl) lib/rumbl_web/endpoint.ex:1: RumblWeb.Endpoint.instrument/4
(phoenix) lib/phoenix/router.ex:275: Phoenix.Router.__call__/1
(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:34: Phoenix.Endpoint.Cowboy2Handler.init/2









share|improve this question

























  • What are those weird vertical bars in your snippets? The leftover after copy-pasting code? Please correct the snippets to be valid Elixir.

    – Aleksei Matiushkin
    Nov 25 '18 at 15:20
















1















Following along with the Programming Phoenix 1.4 book. The module worked fine when I was using a manual database, but when I tried to switch my accounts.ex file (like the book told me to do), it broke:



defmodule Rumbl.Accounts do
alias Rumbl.Repo

def get_user(id) do
Repo.get(User, id)
end

def get_user!(id) do
Repo.get!(User, id)
end

def get_user_by(params) do
Repo.get_by(User, params)
end

def list_users do
Repo.all(User)
end
end


Here's the full error I get when I changed my account.ex file:



[error] #PID<0.732.0> running RumblWeb.Endpoint (connection #PID<0.731.0>, stream id 1) terminated
Server: localhost:4000 (http)
Request: GET /users
** (exit) an exception was raised:
** (Protocol.UndefinedError) protocol Ecto.Queryable not implemented for User, the given module does not exist. This protocol is implemented for: Atom, BitString, Ecto.Query, Ecto.SubQuery, Tuple
(ecto) lib/ecto/queryable.ex:40: Ecto.Queryable.Atom.to_query/1
(ecto) lib/ecto/repo/queryable.ex:14: Ecto.Repo.Queryable.all/3
(rumbl) lib/rumbl_web/controllers/user_controller.ex:7: RumblWeb.UserController.index/2
(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
(rumbl) lib/rumbl_web/endpoint.ex:1: RumblWeb.Endpoint.instrument/4
(phoenix) lib/phoenix/router.ex:275: Phoenix.Router.__call__/1
(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:34: Phoenix.Endpoint.Cowboy2Handler.init/2









share|improve this question

























  • What are those weird vertical bars in your snippets? The leftover after copy-pasting code? Please correct the snippets to be valid Elixir.

    – Aleksei Matiushkin
    Nov 25 '18 at 15:20














1












1








1








Following along with the Programming Phoenix 1.4 book. The module worked fine when I was using a manual database, but when I tried to switch my accounts.ex file (like the book told me to do), it broke:



defmodule Rumbl.Accounts do
alias Rumbl.Repo

def get_user(id) do
Repo.get(User, id)
end

def get_user!(id) do
Repo.get!(User, id)
end

def get_user_by(params) do
Repo.get_by(User, params)
end

def list_users do
Repo.all(User)
end
end


Here's the full error I get when I changed my account.ex file:



[error] #PID<0.732.0> running RumblWeb.Endpoint (connection #PID<0.731.0>, stream id 1) terminated
Server: localhost:4000 (http)
Request: GET /users
** (exit) an exception was raised:
** (Protocol.UndefinedError) protocol Ecto.Queryable not implemented for User, the given module does not exist. This protocol is implemented for: Atom, BitString, Ecto.Query, Ecto.SubQuery, Tuple
(ecto) lib/ecto/queryable.ex:40: Ecto.Queryable.Atom.to_query/1
(ecto) lib/ecto/repo/queryable.ex:14: Ecto.Repo.Queryable.all/3
(rumbl) lib/rumbl_web/controllers/user_controller.ex:7: RumblWeb.UserController.index/2
(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
(rumbl) lib/rumbl_web/endpoint.ex:1: RumblWeb.Endpoint.instrument/4
(phoenix) lib/phoenix/router.ex:275: Phoenix.Router.__call__/1
(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:34: Phoenix.Endpoint.Cowboy2Handler.init/2









share|improve this question
















Following along with the Programming Phoenix 1.4 book. The module worked fine when I was using a manual database, but when I tried to switch my accounts.ex file (like the book told me to do), it broke:



defmodule Rumbl.Accounts do
alias Rumbl.Repo

def get_user(id) do
Repo.get(User, id)
end

def get_user!(id) do
Repo.get!(User, id)
end

def get_user_by(params) do
Repo.get_by(User, params)
end

def list_users do
Repo.all(User)
end
end


Here's the full error I get when I changed my account.ex file:



[error] #PID<0.732.0> running RumblWeb.Endpoint (connection #PID<0.731.0>, stream id 1) terminated
Server: localhost:4000 (http)
Request: GET /users
** (exit) an exception was raised:
** (Protocol.UndefinedError) protocol Ecto.Queryable not implemented for User, the given module does not exist. This protocol is implemented for: Atom, BitString, Ecto.Query, Ecto.SubQuery, Tuple
(ecto) lib/ecto/queryable.ex:40: Ecto.Queryable.Atom.to_query/1
(ecto) lib/ecto/repo/queryable.ex:14: Ecto.Repo.Queryable.all/3
(rumbl) lib/rumbl_web/controllers/user_controller.ex:7: RumblWeb.UserController.index/2
(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
(rumbl) lib/rumbl_web/endpoint.ex:1: RumblWeb.Endpoint.instrument/4
(phoenix) lib/phoenix/router.ex:275: Phoenix.Router.__call__/1
(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:34: Phoenix.Endpoint.Cowboy2Handler.init/2






elixir phoenix-framework ecto






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 25 '18 at 21:57









Sheharyar

45.8k12109162




45.8k12109162










asked Nov 25 '18 at 10:14









cggcgg

203




203













  • What are those weird vertical bars in your snippets? The leftover after copy-pasting code? Please correct the snippets to be valid Elixir.

    – Aleksei Matiushkin
    Nov 25 '18 at 15:20



















  • What are those weird vertical bars in your snippets? The leftover after copy-pasting code? Please correct the snippets to be valid Elixir.

    – Aleksei Matiushkin
    Nov 25 '18 at 15:20

















What are those weird vertical bars in your snippets? The leftover after copy-pasting code? Please correct the snippets to be valid Elixir.

– Aleksei Matiushkin
Nov 25 '18 at 15:20





What are those weird vertical bars in your snippets? The leftover after copy-pasting code? Please correct the snippets to be valid Elixir.

– Aleksei Matiushkin
Nov 25 '18 at 15:20












1 Answer
1






active

oldest

votes


















2















Ecto.Queryable not implemented for User, the given module does not exist.




The error is pretty clear, meaning you don't have a module called User (it's probably Rumbl.User or Rumbl.Accounts.User in your application).



Assuming you have indeed created the ecto schema Rumbl.User, you should:





  1. Either alias it in the module you use:



    alias Rumbl.User



  2. or use the fully-qualified name of the module:



    Repo.get(Rumbl.User, id)







share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53466494%2fecto-queryable-not-implemented-for-user-phoenix-error%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2















    Ecto.Queryable not implemented for User, the given module does not exist.




    The error is pretty clear, meaning you don't have a module called User (it's probably Rumbl.User or Rumbl.Accounts.User in your application).



    Assuming you have indeed created the ecto schema Rumbl.User, you should:





    1. Either alias it in the module you use:



      alias Rumbl.User



    2. or use the fully-qualified name of the module:



      Repo.get(Rumbl.User, id)







    share|improve this answer






























      2















      Ecto.Queryable not implemented for User, the given module does not exist.




      The error is pretty clear, meaning you don't have a module called User (it's probably Rumbl.User or Rumbl.Accounts.User in your application).



      Assuming you have indeed created the ecto schema Rumbl.User, you should:





      1. Either alias it in the module you use:



        alias Rumbl.User



      2. or use the fully-qualified name of the module:



        Repo.get(Rumbl.User, id)







      share|improve this answer




























        2












        2








        2








        Ecto.Queryable not implemented for User, the given module does not exist.




        The error is pretty clear, meaning you don't have a module called User (it's probably Rumbl.User or Rumbl.Accounts.User in your application).



        Assuming you have indeed created the ecto schema Rumbl.User, you should:





        1. Either alias it in the module you use:



          alias Rumbl.User



        2. or use the fully-qualified name of the module:



          Repo.get(Rumbl.User, id)







        share|improve this answer
















        Ecto.Queryable not implemented for User, the given module does not exist.




        The error is pretty clear, meaning you don't have a module called User (it's probably Rumbl.User or Rumbl.Accounts.User in your application).



        Assuming you have indeed created the ecto schema Rumbl.User, you should:





        1. Either alias it in the module you use:



          alias Rumbl.User



        2. or use the fully-qualified name of the module:



          Repo.get(Rumbl.User, id)








        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 25 '18 at 23:17









        Sheharyar

        45.8k12109162




        45.8k12109162










        answered Nov 25 '18 at 15:20









        Aleksei MatiushkinAleksei Matiushkin

        83.1k95694




        83.1k95694
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53466494%2fecto-queryable-not-implemented-for-user-phoenix-error%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Costa Masnaga

            Fotorealismo

            Sidney Franklin