Giter VIP home page Giter VIP logo

Comments (10)

riverrun avatar riverrun commented on August 16, 2024

Thanks for pointing this out. I'll sort this out later today.

from openmaize.

 avatar commented on August 16, 2024

Awesome. I hope what I said made sense. It was kind of hard to word it. Thanks!

Sent from my iPhone

On Feb 16, 2016, at 8:45 PM, David Whitlock [email protected] wrote:

Thanks for pointing this out. I'll sort this out later today.


Reply to this email directly or view it on GitHub.

from openmaize.

 avatar commented on August 16, 2024

Here are my versions:

{:phoenix, "~> 1.1.4"}, {:phoenix_ecto, "~> 2.0"}, {:postgrex, ">= 0.11.0"}, {:phoenix_html, "~> 2.3"}, {:phoenix_live_reload, "~> 1.0", only: :dev}, {:gettext, "~> 0.9"}, {:cowboy, "~> 1.0"}, {:openmaize, git: "https://github.com/elixircnx/openmaize.git"}, {:not_qwerty123, "~> 1.0"}]

I tested out the new version, and I'm getting a new error further in the process. Here is the stack trace:

Request: GET /dashboard/user_profiles/new ** (exit) an exception was raised: ** (UndefinedFunctionError) undefined function Openmaize.UserData.__schema__/2 (openmaize) Openmaize.UserData.__schema__(:association, :user_profile) (ecto) lib/ecto/association.ex:112: Ecto.Association.association_from_model!/2 (ecto) lib/ecto.ex:468: Ecto.build_assoc/3 (app) web/controllers/user_profile_controller.ex:24: app.userProfileController.new/3 (app) web/controllers/user_profile_controller.ex:1: app.userProfileController.action/2 (app) web/controllers/user_profile_controller.ex:1: app.userProfileController.phoenix_controller_pipeline/2 (app) lib/phoenix/router.ex:261: app.Router.dispatch/2 (app) web/router.ex:1: app.Router.do_call/2 (app) lib/app/endpoint.ex:1: app.Endpoint.phoenix_pipeline/1 (app) lib/plug/debugger.ex:93: app.Endpoint."call (overridable 3)"/2 (app) lib/phoenix/endpoint/render_errors.ex:34: app.Endpoint.call/2 (plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4 (cowboy) src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4

Once build_assoc gets called, here is that function:

def build_assoc(%{__struct__: model} = struct, assoc, attributes \\ %{}) do 468 assoc = Ecto.Association.association_from_model!(model, assoc) 469 assoc.__struct__.build(assoc, struct, Dict.delete(attributes, :__meta__)) 470 end

This is the next step:

def association_from_model!(model, assoc) do 112 model.__schema__(:association, assoc) || 113 raise ArgumentError, "model #{inspect model} does not have association #{inspect assoc}" 114 end

That is where the error is encountered. Please excuse the line numbers inside the functions. Got to love copy and paste.

from openmaize.

riverrun avatar riverrun commented on August 16, 2024

Can you give me an example of a struct that does work with your example?

On an unrelated note, I've removed the :not_qwerty123 optional dependency - more details at #26.

from openmaize.

riverrun avatar riverrun commented on August 16, 2024

Looking at the ecto documentation, it seems that build_assoc needs the first argument to be a struct returned by Repo.get (or a similar function). Maybe if you create a struct by running user = Repo.get(User, current_user.id) and send that to build_assoc, you might have more success.

from openmaize.

 avatar commented on August 16, 2024

That's a good idea. I will give that a shot. If it doesn't cause any conflicts, I would like to keep notqwerty to enforce some basic password rules.

Sent from my iPhone

On Feb 17, 2016, at 11:15 PM, David Whitlock [email protected] wrote:

Looking at the ecto documentation, it seems that build_assoc needs the first argument to be a struct returned by Repo.get (or a similar function). Maybe if you create a struct by running user = Repo.get(User, current_user.id) and send that to build_assoc, you might have more success.


Reply to this email directly or view it on GitHub.

from openmaize.

riverrun avatar riverrun commented on August 16, 2024

I've just updated master to use the user_model in the :openmaize config (so it creates a struct from your User model combined with the information in the JSON Web Token). I think that will give you what you're looking for.

from openmaize.

 avatar commented on August 16, 2024

Thanks for the quick turnarounds on this, but that fix didn't work. Its giving the same error. Its ok, I will just have to swap out auth frameworks so I can continue on.

from openmaize.

riverrun avatar riverrun commented on August 16, 2024

I'll look into it further and see what I can come up with.

from openmaize.

riverrun avatar riverrun commented on August 16, 2024

One option is for you to change data into a struct in the controller file - you can do this for just one function or, by overriding the action function, for all the functions in the module.

I think I'm going to change the current_user data back into a map, as this is probably the most flexible data structure to use, and the developers can convert it if they need to.

from openmaize.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.