-
Notifications
You must be signed in to change notification settings - Fork 529
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
Monkeypatch activerecord relations to work with rails >=5.2.0rc2 #435
Monkeypatch activerecord relations to work with rails >=5.2.0rc2 #435
Conversation
@bbonislawski This is some great code, thanks! Just one small issue is the module CatchHasOneDeletionException
def delete(...)
...
end
end
ActiveRecord::Associations::HasOneAssociation.include CatchHasOneDeletionException Or which ever module name you feel better describes what you're achieving. |
f6a58f8
to
78f5819
Compare
@BenMorganIO fixed. I had to use |
Looks like JRuby is failing: |
@BenMorganIO there is a problem with sqlite3 jdbc adapter(it's based on activerecord Any ideas? |
Crap. I'm not that into the ruby world ATM to be able to provide meaningful thoughts. Maybe someone else will have some thoughts on this. cc @jhawthorn Edit: was going to ping him about this, but his profile on the solidus slack says he's vacationing until March 26th. I apologize @bbonislawski you may have to wait for a little for this one. I think JRuby should remain to have support, but if they aren't going to get things working nicely for the upcoming rails 5.2, then we may have to sink them if they don't swim. I would recommend using your branch for the time being until a new release is cut. |
@@ -14,7 +14,7 @@ env: | |||
- RAILS='~> 4.2.0' | |||
- RAILS='~> 5.0.0' | |||
- RAILS='~> 5.1.0' | |||
- RAILS='~> 5.2.0.beta2' | |||
- RAILS='~> 5.2.0.rc2' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you need to update env: RAILS='~> 5.2.0.beta2'
line in allowed_failures
section?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch @eitoball . Fixed
78f5819
to
65649aa
Compare
FWIW here is a gist to reproduce the issue: For now we're using the following hack in our soft deleteable models to work around: def destroyed?
if @in_save
super
else
paranoia_destroyed?
end
end
def save(*args)
@in_save = true
begin
return super(*args)
ensure
@in_save = false
end
end |
Thanks for this patch @bbonislawski |
Since this thing rails/rails@b0fc04a got merged into rails, AR raises an exception and don't destroy record since relations seem not destroyed(because they're soft deleted instead of destroyed).
We can monkeypatch ActiveRecord this way, but if someone has better solution, I will be glad.