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

Actable model is saved twice #82

Open
allenwq opened this issue Oct 13, 2016 · 10 comments
Open

Actable model is saved twice #82

allenwq opened this issue Oct 13, 2016 · 10 comments

Comments

@allenwq
Copy link
Contributor

allenwq commented Oct 13, 2016

actable.save will trigger two update queries and the after_save callback is called twice.

I think this is because of the bi-directional auto_save: true on actings as and actable model.

@manuelmeurer
Copy link
Collaborator

We need both autosaves AFAICS. Happy to remove one if there's an alternative though! :)

@allenwq
Copy link
Contributor Author

allenwq commented Mar 22, 2017

not asking to remove one, but the issue is after_save callbacks are called twice, and duplicated queries are generated, isn't that an issue with the gem ?

@manuelmeurer
Copy link
Collaborator

Yeah sure, it might be. If you know how to fix it, please submit a PR!

@allenwq
Copy link
Contributor Author

allenwq commented Mar 23, 2017

@manuelmeurer We have a workaround that uses after_save instead of autosave and that fixed the issue on our project, not sure if you are interested in the way we are doing.

however, I think we should open the issue until someone submits a PR, what you think ? 😄

@manuelmeurer
Copy link
Collaborator

manuelmeurer commented Mar 23, 2017

Can you post the code of your workaround? I'm happy to try it out to see if it fixes the problem! 😄

@manuelmeurer manuelmeurer reopened this Mar 23, 2017
@allenwq
Copy link
Contributor Author

allenwq commented Mar 24, 2017

@manuelmeurer Thanks ! 😄

Here's the commit: Coursemology@ca24c95

We have tested and used in our production product ( 80+ tables/models ) and turns out to be pretty stable.

@manuelmeurer
Copy link
Collaborator

Could you test if this is still a problem with the current gem version (2.2.0)?
I just tried it out on the console and the after_save callbacks on the supermodel and submodel were only called once each.

@allenwq
Copy link
Contributor Author

allenwq commented Apr 9, 2017

@manuelmeurer Can let me know which rails version that you were testing on ?

@manuelmeurer
Copy link
Collaborator

4.2.8

@allenwq
Copy link
Contributor Author

allenwq commented Apr 10, 2017

Let you know first @manuelmeurer, it still happens to us with 2.2.1 in rails 4.2.8.

I will see if can get an example app to reproduce this, but that will take some time...

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

2 participants