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

Nested attributes support #4

Closed
flvrone opened this issue Oct 17, 2018 · 3 comments
Closed

Nested attributes support #4

flvrone opened this issue Oct 17, 2018 · 3 comments

Comments

@flvrone
Copy link
Collaborator

flvrone commented Oct 17, 2018

Hey @janko-m,

I've just found another bug I believe, because I was trying to do exact same thing as you described here:
https://github.com/shrinerb/shrine/blob/master/doc/multiple_files.md
But with Mongoid (and currently supported embedded models on my branch), and well, it just skips all the Shrine uploaders stuff (kind of). It just saves file_data (if file attribute is just called file), but there's no uploading or validations. (I must use Mongoid 6.4 though).

@flvrone
Copy link
Collaborator Author

flvrone commented Oct 18, 2018

I've added tests for it, confirming that bug exists, but only for embedded models:
https://github.com/LinkUpStudioUA/shrine-mongoid/tree/nested-attributes

@flvrone
Copy link
Collaborator Author

flvrone commented Oct 18, 2018

OK, I've figured out that mongoid does not run callbacks for embedded models, and even cascade_callbacks association option does not help for some reason, not sure what's wrong there.
So I came up with a "workaround" test here: https://github.com/LinkUpStudioUA/shrine-mongoid/blob/nested-attributes/test/mongoid_test.rb#L280

So, if that's the only way to make it work - I believe such workaround should be described in README file.

Waiting for your review, @janko-m

@flvrone
Copy link
Collaborator Author

flvrone commented Oct 23, 2018

OK, this is actually bug in #swap method for embedded records, once it will be fixed,
cascade_callbacks association option will help.

@flvrone flvrone closed this as completed Oct 23, 2018
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

1 participant