Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

embedded_schema support / best practises #17

Open
casio opened this issue Oct 28, 2015 · 4 comments
Open

embedded_schema support / best practises #17

casio opened this issue Oct 28, 2015 · 4 comments

Comments

@casio
Copy link

casio commented Oct 28, 2015

Was using Blacksmith today for the first time. Nice lib, thanks!

I'm trying to use an Ecto embedded_schema in Forge.register, which leads to warnings about embedded data having to be assigned via their own changeset in Ecto.

My workaround is to manually add said changesets, now, which might become tedious when working with embedded schemas a lot.

Is support for this in the works, or are there other, easier workarounds?

@batate
Copy link
Owner

batate commented Oct 28, 2015

Carsten, Eric is working on some Ecto changes for our app, but they are
still under way.

Eric? What do you think?

-bt

On Wed, Oct 28, 2015 at 1:42 PM, Carsten Kraus notifications@github.com
wrote:

Was using Blacksmith today for the first time. Nice lib, thanks!

I'm trying to use an Ecto embedded_schema in Forge.register, which leads
to warnings about embedded data having to be assigned via their own
changeset in Ecto.

My workaround is to manually add said changesets, now, which might become
tedious when working with embedded schemas a lot.

Is support for this in the works, or are there other, easier workarounds?


Reply to this email directly or view it on GitHub
#17.

Bruce Tate | CTO | 512.772.4312

i__can__make__it__better_.com_ http://icanmakeitbetter.com

Innovation + Research. Made Simple

@ericmj
Copy link
Collaborator

ericmj commented Nov 1, 2015

We are working on a 0.2.0 release that will better support Ecto. In our own app we have the following code in our blacksmith save config to persist embedded associations:

  def save(struct) do
    module    = struct.__struct__
    model     = struct(struct.__struct__, [])
    changes   = Map.from_struct(struct) |> Map.take(module.__schema__(:fields))
    changeset = Ecto.Changeset.change(model, changes)
    MyRepo.insert!(changeset)
  end

@casio
Copy link
Author

casio commented Nov 3, 2015

Cool, thanks @ericmj - working nicely in my app, too!

Should we leave the ticket open, whatsoever?

@ericmj
Copy link
Collaborator

ericmj commented Nov 4, 2015

Yes, we are going to provide an out-of-box solution

Eric Meadows-Jönsson

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants